Implement UTF-8 to UTF-16 conversion function.

This commit is contained in:
Michael Jumper 2013-08-05 22:23:30 -07:00
parent 94888d1f47
commit f00cb33619
2 changed files with 24 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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);