Unicode string badly displayed with _() macro

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
-4ian-
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Sep 12, 2011 7:35 pm

Unicode string badly displayed with _() macro

Post by -4ian- »

Hi,

I'm using wxWidgets 2.9.3, unicode build. The strings in my program are written in French, and then translated into English thanks to the internalization features provided by wxWidgets: In particular, each string is surrounded by _() macro. Sources files are saved using UTF8 encoding and some strings can contain accentuated characters. For example:

Code: Select all

    MyFrame *frame = new MyFrame(_("Accentué"));
However, when launching the application, the string is displayed as Accentué.
If I use the macro wxT, the string is displayed properly but it won't be taken into account into translations catalogs.
( I also tried to manually put a L before the string ( i.e : _(L"Accentué") ) and it is then displayed also properly, but I'm not sure it will work with gettext, and moreover wxSmith and other RAD programs output code directly with the L ).

The documentation and some websites declares that _() is a superset of _T(), so _(_T("str")) should be written just _("str"), so I do not understand why it works with wxT() and not with _() ?
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: Unicode string badly displayed with _() macro

Post by catalin »

Try

Code: Select all

    MyFrame *frame = new MyFrame(_(wxString::FromUTF8("Accentué")));
-4ian-
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Sep 12, 2011 7:35 pm

Re: Unicode string badly displayed with _() macro

Post by -4ian- »

Indeed, it works properly with this function call. :)
But in fact it was also working properly by using L or wxT :

Code: Select all

    MyFrame *frame = new MyFrame(_(L"Accentué")); //Works fine
    MyFrame *frame = new MyFrame(_(wxT("Accentué"))); //Works fine
but in all cases, I cannot imagine I have to add an extra function call ( or an extra wxT ) to each string to be translated ( and as said before, I'm using RAD programs that output the code only with a simple _() ).
Moreover, I think it is really weird that the last form works, while as said before _() is a superset of _T(), so _(_T("str")) should be written just _("str").
Post Reply