Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // UTF-8 -> cp1251
- STRING
- Tools::icu_u2s(CHAR *from)
- {
- UText *ut = NULL;
- UChar uc[ICU_CONV_BUFFER];
- UErrorCode status = U_ZERO_ERROR;
- ut = utext_openUTF8(ut, from, -1, &status);
- utext_extract(ut, 0, strlen(from), uc, ICU_CONV_BUFFER, &status);
- char target[ICU_CONV_BUFFER];
- UConverter *conv;
- conv = ucnv_open("windows-1251", &status);
- ucnv_fromUChars(conv, target, ICU_CONV_BUFFER, uc, -1, &status);
- ucnv_close(conv);
- return _S(target);
- }
Add Comment
Please, Sign In to add comment