Illegal byte sequence's error on strings in Unicode

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Experienced Solver
Experienced Solver
Posts: 61
Joined: Tue May 24, 2005 9:46 am

Illegal byte sequence's error on strings in Unicode

Post by ioio » Tue Dec 20, 2005 4:09 pm

I have switched to Unicode when building my apps.
On the wx ansi build, all strings with accentuate characters are finely compiled, but with the unicode build, I get this error on any strings including them :

converting to execution character set: Illegal byte sequence

Why is that happening, and how to resolv it ?

I live to help wx-kind
I live to help wx-kind
Posts: 150
Joined: Fri Oct 08, 2004 2:05 pm
Location: Europe

Post by chris » Tue Dec 20, 2005 9:59 pm

Hi ioio,

When gcc is parsing your source code it does so assuming a certain charset for the string and character constants in the source code. In the current charset used by gcc ( I think it is UTF-8 ) it expects the special characters to be in Unicode, but your chars are in another charset (probably iso-8859-1).
You may either convert those characters to their respective Unicode codes or change the charset used to parse the source to your local charset; for the latter have a look at the preprocessor options of gcc: here is the online version for gcc 3.4.3. You may want to look at -fexec-charset, -fwide-exec-charset and related options.

HTH, Chris

Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn

Post by leio » Wed Dec 21, 2005 12:13 am

Safest is to not have any character in source files that are above ASCII-7 scope (bytes whose integer value is above 127). You can use hex or octal notation to express such characters if you are putting non-english string literals in your source files for some reason.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD -
Developer of wxGTK;
gtk+ port maintainer of OMGUI -

Post Reply