I am trying to convert utf-8 string with special quote symbols to Latin1. Code works perfectly on Windows, but omits the symbols on g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0
String: Latin1: APOST ( ‘ ) QUOTE ( “ ) ( « » )
Windows: Latin1: APOST ( ' ) QUOTE ( " ) ( < > )
Ubuntu: Latin1: APOST ( ) QUOTE ( ) ( )
Hex representation of converted strings:
HW: 41 50 4F 53 54 20 28 20 27 20 29 20 51 55 4F 54 45 20 28 20 22 20 29 20 28 20 3C 20 3E 20 29
HU: 41 50 4F 53 54 20 28 20 20 29 20 51 55 4F 54 45 20 28 20 20 29 20 28 20 20 20 29
const unsigned char utf8[] = { 0x41, 0x50, 0x4f, 0x53, 0x54, 0x20, 0x28, 0x20, 0xe2, 0x80, 0x98, 0x20, 0x29, 0x20, 0x51, 0x55, 0x4f, 0x54, 0x45, 0x20, 0x28, 0x20, 0xe2, 0x80, 0x9c, 0x20, 0x29, 0x20, 0x28, 0x20, 0xc2, 0xab, 0x20, 0xc2, 0xbb, 0x20, 0x29, 0x00 };
boost::locale::generator loc_g;
std::string ansi0 = boost::locale::conv::from_utf<char>((const char*)utf8, loc_g.generate("Latin1"));
printf("Latin1: %s", ansi0.c_str());
How to get on Ubuntu result that is similar to Windows?
Results on Ubuntu using iconv
ASCII: APOST ( ' ) QUOTE ( " ) ( << >> )
Latin1: APOST ( ` ) QUOTE ( " ) ( . . )
ISO-8859-1: APOST ( ` ) QUOTE ( " ) ( . . )