Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstring>
- #include <iostream>
- int main(int argc, char* argv[])
- {
- const char text[] = "olé" ;
- const wchar_t wtext[] = L"olé" ;
- std::cout << "sizeof(char) : " << sizeof(char) << std::endl ;
- std::cout << "text : " << text << std::endl ;
- std::cout << "sizeof(text) : " << sizeof(text) << std::endl ;
- std::cout << "strlen(text) : " << strlen(text) << std::endl ;
- std::cout << "text(binary) :" ;
- for(size_t i = 0, iMax = strlen(text); i < iMax; ++i)
- {
- std::cout << " " << static_cast<unsigned int>(static_cast<unsigned char>(text[i])) ;
- }
- std::cout << std::endl << std::endl ;
- std::cout << "sizeof(wchar_t) : " << sizeof(wchar_t) << std::endl ;
- //std::cout << "wtext : " << wtext << std::endl ; <- error
- std::cout << "wtext : UNABLE TO CONVERT NATIVELY." << std::endl ;
- std::wcout << L"wtext : " << wtext << std::endl;
- std::cout << "sizeof(wtext) : " << sizeof(wtext) << std::endl ;
- std::cout << "wcslen(wtext) : " << wcslen(wtext) << std::endl ;
- std::cout << "wtext(binary) :" ;
- for(size_t i = 0, iMax = wcslen(wtext); i < iMax; ++i)
- {
- std::cout << " " << static_cast<unsigned int>(static_cast<unsigned short>(wtext[i])) ;
- }
- std::cout << std::endl << std::endl ;
- return 0;
- }
- sizeof(char) : 1
- text : olé
- sizeof(text) : 5
- strlen(text) : 4
- text(binary) : 111 108 195 169
- sizeof(wchar_t) : 4
- wtext : UNABLE TO CONVERT NATIVELY.
- sizeof(wtext) : 16
- wcslen(wtext) : 3
- wtext(binary) : 111 108 233
- UCS2String ConvertToUCS2( const UTF8String &str );
- UTF8String ConvertToUTF8( const UCS2String &str );
Advertisement
Add Comment
Please, Sign In to add comment