Guest User

Untitled

a guest
Nov 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // UTF-8 -> cp1251
  2. STRING
  3. Tools::icu_u2s(CHAR *from)
  4. {
  5. UText *ut = NULL;
  6. UChar uc[ICU_CONV_BUFFER];
  7. UErrorCode status = U_ZERO_ERROR;
  8.  
  9. ut = utext_openUTF8(ut, from, -1, &status);
  10. utext_extract(ut, 0, strlen(from), uc, ICU_CONV_BUFFER, &status);
  11.  
  12. char target[ICU_CONV_BUFFER];
  13. UConverter *conv;
  14.  
  15. conv = ucnv_open("windows-1251", &status);
  16. ucnv_fromUChars(conv, target, ICU_CONV_BUFFER, uc, -1, &status);
  17. ucnv_close(conv);
  18.  
  19. return _S(target);
  20. }
Add Comment
Please, Sign In to add comment