Guest User

Untitled

a guest
Oct 17th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #include <cstring>
  2. #include <iostream>
  3.  
  4. int main(int argc, char* argv[])
  5. {
  6. const char text[] = "olé" ;
  7. const wchar_t wtext[] = L"olé" ;
  8.  
  9. std::cout << "sizeof(char) : " << sizeof(char) << std::endl ;
  10. std::cout << "text : " << text << std::endl ;
  11. std::cout << "sizeof(text) : " << sizeof(text) << std::endl ;
  12. std::cout << "strlen(text) : " << strlen(text) << std::endl ;
  13.  
  14. std::cout << "text(binary) :" ;
  15.  
  16. for(size_t i = 0, iMax = strlen(text); i < iMax; ++i)
  17. {
  18. std::cout << " " << static_cast<unsigned int>(static_cast<unsigned char>(text[i])) ;
  19. }
  20.  
  21. std::cout << std::endl << std::endl ;
  22.  
  23. std::cout << "sizeof(wchar_t) : " << sizeof(wchar_t) << std::endl ;
  24. //std::cout << "wtext : " << wtext << std::endl ; <- error
  25. std::cout << "wtext : UNABLE TO CONVERT NATIVELY." << std::endl ;
  26. std::wcout << L"wtext : " << wtext << std::endl;
  27.  
  28. std::cout << "sizeof(wtext) : " << sizeof(wtext) << std::endl ;
  29. std::cout << "wcslen(wtext) : " << wcslen(wtext) << std::endl ;
  30.  
  31. std::cout << "wtext(binary) :" ;
  32.  
  33. for(size_t i = 0, iMax = wcslen(wtext); i < iMax; ++i)
  34. {
  35. std::cout << " " << static_cast<unsigned int>(static_cast<unsigned short>(wtext[i])) ;
  36. }
  37.  
  38. std::cout << std::endl << std::endl ;
  39.  
  40.  
  41. return 0;
  42. }
  43.  
  44. sizeof(char) : 1
  45. text : olé
  46. sizeof(text) : 5
  47. strlen(text) : 4
  48. text(binary) : 111 108 195 169
  49.  
  50. sizeof(wchar_t) : 4
  51. wtext : UNABLE TO CONVERT NATIVELY.
  52. sizeof(wtext) : 16
  53. wcslen(wtext) : 3
  54. wtext(binary) : 111 108 233
  55.  
  56. UCS2String ConvertToUCS2( const UTF8String &str );
  57. UTF8String ConvertToUTF8( const UCS2String &str );
Advertisement
Add Comment
Please, Sign In to add comment