Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: geronet on August 02, 2006, 06:17:19 pm

Title: Problems with umlaut in wxSmith
Post by: geronet on August 02, 2006, 06:17:19 pm
Hello ;)

wxSmith is a great Tool, but if i use an umlaut like "°C" in a dialog i get this:

(http://www.directupload.net/images/060802/temp/8FOwK7Hz.jpg) (http://www.directupload.net/show/d/777/8FOwK7Hz.jpg)

I wanted to compile with unicode enabled, but there i get errors with every string in the code.. I don't know why. How can i fix this problem?

Thanks in advance, Stefan
Title: Re: Problems with umlaut in wxSmith
Post by: MortenMacFly on August 02, 2006, 06:56:37 pm
I wanted to compile with unicode enabled, but there i get errors with every string in the code.. I don't know why. How can i fix this problem?
There is a nice article on how to prepare wxWidgets code for unicode e.g here: http://www.wxwindows.org/manuals/2.6.3/wx_unicode.html (http://www.wxwindows.org/manuals/2.6.3/wx_unicode.html). Keep in mind that you have to compile the wxWidgets lib(s) for unicode, too and setup your C::B project appropriately (or use the wizard to create a stub for you).

With regards, Morten.
Title: Re: Problems with umlaut in wxSmith
Post by: geronet on August 03, 2006, 05:57:02 pm
And what should i do without unicode?
Title: Re: Problems with umlaut in wxSmith
Post by: MortenMacFly on August 03, 2006, 06:02:55 pm
And what should i do without unicode?
I thought your intenetion was to compile unicode. I wonder why you want to design yyour application in ANSI. Does this becasue you have to be compatible to Win9x or similar? Otherwise I'd suggest you start with unicode right from the start...?!
If you want ANSI you could try to use the ASCii code instead, maybe?!
Title: Re: Problems with umlaut in wxSmith
Post by: MortenMacFly on August 03, 2006, 06:07:54 pm
Hmmm... now I wonder: I used the wizard to create a wxWidgets ANSI application and changed the "About" message to:
Code
wxMessageBox(msg, _("Welcome to °C"));
I get a message as attached - thus: This actually works! I'm not sure what you're doing wrong. What's your sys config? (Mine is WXP-SP2, German).
With regards, Morten.

[attachment deleted by admin]
Title: Re: Problems with umlaut in wxSmith
Post by: geronet on August 03, 2006, 10:42:30 pm
I have WinXP SP2 (German), the latest C::B and gcc.

If i change the text label from the program with
Code: c
StaticText3->SetLabel(_T("°C"));
it is correctly displayed, but that's not a solution.

In the .xrc it is also correct:
Code: c
<label>°C</label>

Any Suggestions? (perhaps in German?) ;)
Title: Re: Problems with umlaut in wxSmith
Post by: geronet on August 04, 2006, 09:14:25 pm
If i try to compile with unicode enabled, i get a lot of errors with every string:

main.cpp:213:1: converting to execution character set: Illegal byte sequence

Line 213:
           wxMessageBox(_T("Konfigurationsdatei ist beschädigt!"), _T("Fehler"));

The problem is the "ä", if i delete it the error is gone...
Title: Re: Problems with umlaut in wxSmith
Post by: geronet on August 04, 2006, 10:29:39 pm
I'm stuck now. If i compile in ANSI mode, i get dialogs like shown in the first post.
If i compile in unicode mode, i get errors because of the char '°' in the string shown here:
Code: c
Textfield[i]->SetLabel(wxString::Format(_T("%.1f°C"), *(T[i].value)));

And now? I don't know..
Title: Re: Problems with umlaut in wxSmith
Post by: kagerato on August 05, 2006, 05:57:59 pm
I'm stuck now. If i compile in ANSI mode, i get dialogs like shown in the first post.
If i compile in unicode mode, i get errors because of the char '°' in the string shown here:
Code: c
Textfield[i]->SetLabel(wxString::Format(_T("%.1f°C"), *(T[i].value)));

And now? I don't know..

Are your source files using an ANSI encoding?  If so, try using UTF-8.
Title: Re: Problems with umlaut in wxSmith
Post by: geronet on August 05, 2006, 10:05:15 pm
Code: cpp
 Textfield[i]->SetLabel(wxString::Format(_T("%.1f\x00B0C"), *(T[i].value)));
with the help of the chart
http://www.unicode.org/charts/PDF/U0080.pdf

displays the character correctly on Linux, with msw i get some undefined character.
Maybe the cpp-file on Windows is ANSI? How can i change that?
On Linux i get
Quote
file main.cpp
main.cpp: ISO-8859 C program text, with CRLF, LF line terminators
Title: Re: Problems with umlaut in wxSmith
Post by: geronet on August 06, 2006, 06:01:29 pm
It's ok now, i converted the file to utf-8 with "iconv -f ISO-8859-1 -t UTF-8 main.cpp" and now i have to insert the character
Code
 Textfield[i]->SetLabel(wxString::Format(_T("%.1f°C"), *(T[i].value)));
and it displays correctly ;)

PS: The C:B Editor doesn't show the correct character, it is displayed like here (two bytes, one A with ^on it and a °), but C:B is compiled with unicode enabled?!
Title: Re: Problems with umlaut in wxSmith
Post by: Ceniza on August 06, 2006, 07:53:31 pm
Did you try Edit->File encoding->UTF-8?
Title: Re: Problems with umlaut in wxSmith
Post by: geronet on August 06, 2006, 08:16:36 pm
Ah, that's it :D

Didn't see that menu.. Thanks a lot.