|
|
|
@ -429,37 +429,6 @@ static char** parseUriList(char* text, int* count) |
|
|
|
|
return paths; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Encode a Unicode code point to a UTF-8 stream
|
|
|
|
|
// Based on cutef8 by Jeff Bezanson (Public Domain)
|
|
|
|
|
//
|
|
|
|
|
static size_t encodeUTF8(char* s, unsigned int ch) |
|
|
|
|
{ |
|
|
|
|
size_t count = 0; |
|
|
|
|
|
|
|
|
|
if (ch < 0x80) |
|
|
|
|
s[count++] = (char) ch; |
|
|
|
|
else if (ch < 0x800) |
|
|
|
|
{ |
|
|
|
|
s[count++] = (ch >> 6) | 0xc0; |
|
|
|
|
s[count++] = (ch & 0x3f) | 0x80; |
|
|
|
|
} |
|
|
|
|
else if (ch < 0x10000) |
|
|
|
|
{ |
|
|
|
|
s[count++] = (ch >> 12) | 0xe0; |
|
|
|
|
s[count++] = ((ch >> 6) & 0x3f) | 0x80; |
|
|
|
|
s[count++] = (ch & 0x3f) | 0x80; |
|
|
|
|
} |
|
|
|
|
else if (ch < 0x110000) |
|
|
|
|
{ |
|
|
|
|
s[count++] = (ch >> 18) | 0xf0; |
|
|
|
|
s[count++] = ((ch >> 12) & 0x3f) | 0x80; |
|
|
|
|
s[count++] = ((ch >> 6) & 0x3f) | 0x80; |
|
|
|
|
s[count++] = (ch & 0x3f) | 0x80; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return count; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Decode a Unicode code point from a UTF-8 stream
|
|
|
|
|
// Based on cutef8 by Jeff Bezanson (Public Domain)
|
|
|
|
|
//
|
|
|
|
@ -497,7 +466,7 @@ static char* convertLatin1toUTF8(const char* source) |
|
|
|
|
char* tp = target; |
|
|
|
|
|
|
|
|
|
for (sp = source; *sp; sp++) |
|
|
|
|
tp += encodeUTF8(tp, *sp); |
|
|
|
|
tp += _glfwEncodeUTF8(tp, *sp); |
|
|
|
|
|
|
|
|
|
return target; |
|
|
|
|
} |
|
|
|
@ -2903,7 +2872,7 @@ const char* _glfwGetScancodeNameX11(int scancode) |
|
|
|
|
if (ch == -1) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch); |
|
|
|
|
const size_t count = _glfwEncodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch); |
|
|
|
|
if (count == 0) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|