tool-utf.cpp 682 B

12345678910111213141516171819202122232425262728293031
  1. #include "aFuntool.h"
  2. #include <clocale>
  3. using namespace aFuntool;
  4. int main(int argc, char **argv) {
  5. wchar_t *tmp;
  6. const wchar_t *tmp2 = L"你好";
  7. const char *tmp3 = "你好";
  8. setlocale(LC_ALL, "");
  9. #ifdef aFunWIN32_NO_CYGWIN
  10. convertWideByte(&tmp, tmp3, CP_UTF8);
  11. std::wcout << tmp << std::endl;
  12. std::wcout << tmp2 << std::endl;
  13. for (int i = 0; i < wcslen(tmp); i++)
  14. printf("%x ", tmp[i]);
  15. printf("\n");
  16. for (int i = 0; i < wcslen(tmp2); i++)
  17. printf("%x ", tmp2[i]);
  18. printf("\n");
  19. for (int i = 0; i < strlen(tmp3); i++)
  20. printf("%x ", (unsigned int)tmp3[i]);
  21. printf("\n");
  22. #endif
  23. return 0;
  24. }