Page 1 of 1

Displaying í and the other latin chars..how?

Posted: Wed Jun 18, 2008 8:42 pm
by Joelito
This is my current code to test my problem:

Code: Select all

#include <wx/string.h>

int main() {
	wxPuts(wxT("García")); // Displays "Garc?a"
	return 0;
}
How can I print the correct string: "García"?
Thanks.

Re: Displaying í and the other latin chars..how?

Posted: Wed Jun 18, 2008 11:12 pm
by Double Trouble
Joelito wrote:This is my current code to test my problem:

Code: Select all

#include <wx/string.h>

int main() {
	wxPuts(wxT("García")); // Displays "Garc?a"
	return 0;
}
How can I print the correct string: "García"?
Thanks.
The problem is probably the encoding of the source file (main.cpp or what you're calling it)! You should save in with the encoding Unicode (UTF-8 with signature) !

Good luck!

Posted: Wed Jun 18, 2008 11:37 pm
by Auria
Or look up Unicode tables and escape the character

"blah blah \Ux0085 blah blah"

Or write the app in english and use i18n to get translations

Posted: Sun Jun 22, 2008 4:09 pm
by benedicte
Did you try to use the _ macro instead of wxT ?

Code: Select all

wxPuts(_("García")); 

Posted: Sun Jun 22, 2008 8:02 pm
by masteryoda
Auria wrote:Or look up Unicode tables and escape the character

"blah blah \Ux0085 blah blah"

Or write the app in english and use i18n to get translations
Auria, I tried to do a wxT("whatever\Ux00E0whatever") but it didn't work, can you give me a valid example?

Thanks!

Posted: Sun Jun 22, 2008 11:58 pm
by Auria
I was writing that from the top of my memory, look-up unicode tables for the real character codes (e.g. http://www.fileformat.info/info/unicode/char/search.htm)

A valide example :

Code: Select all

wxT(" Non-english character : \u00FC")

Posted: Mon Jun 23, 2008 8:33 am
by Frank
I don't know about Unix, but on Windows the Console has another Codepage than the GUI (437 or something).

So, a String that is perfectly fine in a GUI app will be garbage in the console.

I never used Unicode, so dunno if it matters in Unicode-Build.

Posted: Tue Jun 24, 2008 1:03 pm
by michel
hello,

In windows console, you can specify the codepage with the command "chcp" :

in program :

Code: Select all

system("chcp 1252");
_setmbcp(1252);
printf("García");
system("pause");
be sure to use a TrueType font (see the console properties)
that is enable to display wide characters.

A second thing that could help :

with gcc compiler, you can specify the codepage of the editor, with the option : -finput-charset=CP1252
By default, utf8 is used.

With msw compiler, I guess it is CP1252.


Michel