I want to port our application (which works on Windows, Linux, Solaris, AIX, etc.), but I have a lot of problem with locale. This code works on all platforms, except OSX:
#define SIZE 1000
int main(int argc, const char * argv[])
{
char dest[SIZE];
wchar_t *dptr = L"árvíztűrőtükörfúrógép";
size_t count = SIZE;
size_t length;
setlocale(LC_CTYPE, "");
length = wcstombs(dest, dptr, count);
printf("%d characters were converted.\n", length);
printf("The converted string is \"%s\"\n\n", dest);
}
Please, help me guys, to print that text in terminal in ISO-8859-2 encoding!
Thanks a lot!
Apple Macintosh uses neither ISO 8859-1 nor ISO 8859-2 encoding. Instead, Apple uses proprietary code tables, namely MacRoman for West European and MacCentralEuropean for East European Languages. WWW browsers on Macintosh (Netscape Navigator 2 and above, and Microsoft Internet Explorer 2.1) automatically perform the recoding from ISO 8859 encoding used on Internet to Macintosh native character set.
Taken from here: http://nl.ijs.si/gnusl/cee/iso8859-2.html
Here’s what you need: http://en.wikipedia.org/wiki/Mac_OS_Roman
And here’s the UTF-8 <-> MacRoman conversion code: http://alienryderflex.com/utf-8/
There are only the modifiers for “u” and “o” (inserted after these letters) to get the “ő” and “ű” characters.
See the table here http://www.alanwood.net/demos/macroman.html
“˝”, Code=0xFD, U+02DD, “double acute accent”, Spacing Modifier Letters
(“Think different” in action)