Implement UTF-8 to UTF-16 conversion function.
This commit is contained in:
parent
94888d1f47
commit
f00cb33619
@ -60,3 +60,22 @@ void guac_rdp_utf16_to_utf8(const unsigned char* utf16, char* utf8, int length)
|
||||
|
||||
}
|
||||
|
||||
void guac_rdp_utf8_to_utf16(const unsigned char* utf8, char* utf16, int length) {
|
||||
|
||||
int i;
|
||||
uint16_t* out_codepoint = (uint16_t*) utf16;
|
||||
|
||||
/* For each UTF-8 character */
|
||||
for (i=0; i<length; i++) {
|
||||
|
||||
/* Get next codepoint */
|
||||
int codepoint;
|
||||
utf8 += guac_utf8_read((const char*) utf8, 4, &codepoint);
|
||||
|
||||
/* Save codepoint as UTF-16 */
|
||||
*(out_codepoint++) = codepoint;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,3 +40,8 @@
|
||||
*/
|
||||
void guac_rdp_utf16_to_utf8(const unsigned char* utf16, char* utf8, int length);
|
||||
|
||||
/**
|
||||
* Convert the given number of UTF-8 characters to UTF-16 characters.
|
||||
*/
|
||||
void guac_rdp_utf8_to_utf16(const unsigned char* utf8, char* utf16, int length);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user