Bug SetClipboard and special characters

Pierrou

Active Member
Joined
Jul 6, 2017
Hi,
I intended to use SetClipboard to export French sentences from my current game to the clipboard and it turns out it doesn't seem to manage special characters such as diacritics.
à é ô and so on become � � �

Is there an easy way to copy special characters to the clipboard too?
{Edit : no big deal if that's not the case}
Thanks!
 
Last edited:

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
Ok, have to look into this. It is a unicode problem. Not sure if our version of GLFW is supporting that. I will report back when I know more.
 

Pierrou

Active Member
Joined
Jul 6, 2017
Again, If I'm the only one needing this, no need to worry I have a plan B, thanks!!
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Well, these little things are always worth investigating. Maybe you can open an issue on github!? So it doesn't get lost.
 

dawlane

Well-Known Member
CX Code Contributor
Joined
Jun 21, 2017
Ok, have to look into this. It is a unicode problem. Not sure if our version of GLFW is supporting that. I will report back when I know more.
As far as I know GLFW 3.0+ supports uni-code utf8 text. All encoding is utf8 const char*. Probably need to use the standard C mbstowcs or one of it's sister functions to convert Cerberus strings.

Here's a little bit of code that I use to get information back from stdout and stderr. I'm sure that it will come in useful some where.
It will probably need a code guard to stop is being included multiple times.

C++:
// Windows, Linux, OSX dirty conversion from multi-byte to wchar
String MBTOWC(const char* ptr, size_t bytes){
    String result;
    int len;
    wchar_t dest;
    mbtowc (NULL, NULL, 0);
    while (bytes>0) {
        len = mbtowc(&dest,ptr,bytes);
        if (len<1) break;
        result+=String(dest,1);
        ptr+=len;
        bytes-=len;
    }
    return result;
}

/*
    Add the abillity to pipe child process output.
    Note that for MS Windows only console mode applications are supported at this time and hasn't been tested yet
    cmd = the full command line to execute.
    ref = the string to receive stdout and stderr.
    returns an integer exit code. 
*/
int ExecutePipe( String cmd, String &ref ){
    FILE* filestream;
    char streambuffer[4096];
    int exitcode=-1;
    #ifdef _WIN32
    filestream=_popen(String(cmd+" 2>&1").ToCString<char>(), "r");
    #else
    filestream=popen(String(cmd+" 2>&1").ToCString<char>(), "r");
    #endif
    if(filestream==NULL ||cmd==""){
        ref=String("Invalid child process.\n");
        #ifdef _WIN32
        _pclose(filestream);
        #else
        pclose(filestream);
        #endif
        return exitcode;
        }
    while(fgets(streambuffer,sizeof(streambuffer), filestream) !=NULL){
        ref+=MBTOWC(streambuffer,sizeof(streambuffer));
    }
    #ifdef _WIN32
    return _pclose(filestream);
    #else
    return pclose(filestream);
    #endif
}
 
Last edited:
Top Bottom