Advertisement
alansam

test_unicode.cpp

Oct 16th, 2020 (edited)
2,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5.   std::string al[] {
  6.     //  Using unicode escapes:
  7.     " \u00e1", // á - U+00E1 - LATIN SMALL LETTER A ACUTE              - UTF-8: 0xC3 0xA1
  8.     " \u00e9", // é - U+00E9 - LATIN SMALL LETTER E WITH ACUTE         - UTF-8: 0xC3 0xA9
  9.     " \u0151", // ő - U+0151 - LATIN SMALL LETTER O WITH DOUBLE ACUTE  - UTF-8: 0xC5 0x91
  10.     " \u0171", // ű - U+0171 - LATIN SMALL LETTER U WITH DOUBLE ACUTE  - UTF-8: 0xC5 0xB1
  11.     "\n",
  12.     //  Using UTF-8 code directly
  13.     " \xc3\xa1", // UTF-8: 0xC3 0xA1
  14.     " \xc3\xa9", // UTF-8: 0xC3 0xA9
  15.     " \xc5\x91", // UTF-8: 0xC5 0x91
  16.     " \xc5\xb1", // UTF-8: 0xC5 0xB1
  17.   };
  18.  
  19.   for (auto u8 : al) {
  20.     std::cout << u8;
  21.   }
  22.   std::cout << std::endl;
  23.  
  24.   return 0;
  25. }
  26.  
  27. /*
  28.  * Output:
  29.  *  á é ő ű
  30.  *  á é ő ű
  31.  */
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement