wxFormBuilder and special charsets
wxFormBuilder and special charsets
I have problems with labels similar to this
"Modalità di pagamento"
where à is the special character \u00E0.
If I write "Modalità di pagamento" as label in wxFormBuilder, the software will display the label erroneously.
If I write "Modalit\u00E0 di pagamento" still erroneously because in the GUIFrame.cpp I will have "Modalitu00E0 di pagamento" without "\".
To resolve the problem I need to have in the GUIFrame.cpp the label "Modalit\u00E0 di pagamento". How can I do this with wxFormBuilder?
"Modalità di pagamento"
where à is the special character \u00E0.
If I write "Modalità di pagamento" as label in wxFormBuilder, the software will display the label erroneously.
If I write "Modalit\u00E0 di pagamento" still erroneously because in the GUIFrame.cpp I will have "Modalitu00E0 di pagamento" without "\".
To resolve the problem I need to have in the GUIFrame.cpp the label "Modalit\u00E0 di pagamento". How can I do this with wxFormBuilder?
Re: wxFormBuilder and special charsets
Which OS and version of wxFormBuilder do you use? I can't reproduce problem on Win7 with wxFB v3.9.0.mrdebug wrote:If I write "Modalità di pagamento" as label in wxFormBuilder, the software will display the label erroneously.
But better create a new issue in their repo - https://github.com/wxFormBuilder/wxFormBuilder
Re: wxFormBuilder and special charsets
Using wxFormBuilder 3.9.0 on Windows 10 with msvc2015.
If I write
"Modalità di pagamento", in the GUIFrame.cpp I will have "Modalità di pagamento" but when I run my software, the software will display "Modalità di pagamento" (à instead of à).
This is a tipical problem of wxWidgets on Windows (on Linux works) so, to prevent this behaviour, it is better to insert the special charset as \u00E0.
The problem is that if I insert in wxFormBuilder \u00E0 I will have in the GUIFrame.cpp u00E0.
If I insert \\u00E0 I will have \\u00E0. Can you verify by creating a software with the label "Modalità di pagamento"?
If I write
"Modalità di pagamento", in the GUIFrame.cpp I will have "Modalità di pagamento" but when I run my software, the software will display "Modalità di pagamento" (à instead of à).
This is a tipical problem of wxWidgets on Windows (on Linux works) so, to prevent this behaviour, it is better to insert the special charset as \u00E0.
The problem is that if I insert in wxFormBuilder \u00E0 I will have in the GUIFrame.cpp u00E0.
If I insert \\u00E0 I will have \\u00E0. Can you verify by creating a software with the label "Modalità di pagamento"?
Re: wxFormBuilder and special charsets
The are three encodings:
a) The one used by the compiler.
b) The one used by the IDE, wxFormBuilder in your case.
c) The one your app uses (e.g. changing the locale) for GUI, and for files.
It's good if a) and b) are the same; otherwise you need special flags to the compiler.
wxWidgets advices (but doesn't force) the simplest, using 7-bit ASCII enconding (English default), and change the locale and load a message catalog.
See
https://docs.wxwidgets.org/trunk/overvi ... _supportin
https://docs.wxwidgets.org/trunk/overvi ... glish.html
a) The one used by the compiler.
b) The one used by the IDE, wxFormBuilder in your case.
c) The one your app uses (e.g. changing the locale) for GUI, and for files.
It's good if a) and b) are the same; otherwise you need special flags to the compiler.
wxWidgets advices (but doesn't force) the simplest, using 7-bit ASCII enconding (English default), and change the locale and load a message catalog.
See
https://docs.wxwidgets.org/trunk/overvi ... _supportin
https://docs.wxwidgets.org/trunk/overvi ... glish.html
Re: wxFormBuilder and special charsets
Really I don't know where to put the special choise.
In Windows I'm using visual studio and as you can see I have unicode everywhere.
Have you got any idea?
In Windows I'm using visual studio and as you can see I have unicode everywhere.
Have you got any idea?
Re: wxFormBuilder and special charsets
The only way seems to insert the text of the labels by hand like this
label01->SetLabel(wxT("Modalit\u00E0 di pagamento"))
label01->SetLabel(wxT("Modalit\u00E0 di pagamento"))
Re: wxFormBuilder and special charsets
Never heard about such problem and code below work for me:mrdebug wrote: If I write
"Modalità di pagamento", in the GUIFrame.cpp I will have "Modalità di pagamento" but when I run my software, the software will display "Modalità di pagamento" (à instead of à).
...
Can you verify by creating a software with the label "Modalità di pagamento"?
Code: Select all
#include <wx/wx.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(NULL, wxID_ANY, "Test", wxDefaultPosition, wxSize(600, 400))
{
wxBoxSizer* Sizer = new wxBoxSizer( wxHORIZONTAL );
m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("Modalità di pagamento"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL );
Sizer->Add( m_staticText2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
this->SetSizer( Sizer );
this->Layout();
this->Centre( wxBOTH );
}
protected:
wxStaticText* m_staticText2;
};
class MyApp : public wxApp
{
public:
bool OnInit()
{
(new MyFrame)->Show();
return true;
}
}; wxIMPLEMENT_APP(MyApp);
Re: wxFormBuilder and special charsets
I can confirm it does not work with wxWidgets 3.1.2 and MSVC 2017 on MSW 10, even if the string is displayed properly in the IDE.
I always say doing using anything but 7-bit ASCII is quite unportable and very brittle and believe that all string literals in the source files should be in 7-bit ASCII wrapped in _() with the translations stored in the localized message catalogs.
If you were using only MSW, you might be able to work around it by checking the use_microsoft_bom in the project properties in wxFormBuilder, but non-MS compilers are likely to dislike having the BOM in the source files...
As it was said, the issue is probably due to different encoding in the source and execution charsets. The literal is being encoded in UTF-8 (assuming you set it so in wxFormBuilder) while on MSW wxString expects ANSI or UTF-16. It would probably work if instead of wxT("Modalità di pagamento") there was wxString::FromUTF8("Modalità di pagamento").
I always say doing using anything but 7-bit ASCII is quite unportable and very brittle and believe that all string literals in the source files should be in 7-bit ASCII wrapped in _() with the translations stored in the localized message catalogs.
If you were using only MSW, you might be able to work around it by checking the use_microsoft_bom in the project properties in wxFormBuilder, but non-MS compilers are likely to dislike having the BOM in the source files...
Re: wxFormBuilder and special charsets
I confirm that the problem can be resolved using wxString::FromUTF8 or using use_microsoft_bom but the software is multiplatform so I can't use use_microsoft_bom.
What do you think about this behaviour? Is it a wxWidgets bug?
What do you think about this behaviour? Is it a wxWidgets bug?
Re: wxFormBuilder and special charsets
Not sure who were you asking but I still believe it is not, see what I wrote in the first three paragraphs of my previous post.mrdebug wrote:Is it a wxWidgets bug?
Edit
There is one more option, I consider it a kludge but it works at least in MSVC 2017, should work in MSVC 2015 as well.
In MSVC IDE right click the source file generated by wxFB containing the problematic string(s). From the menu chose Properties and go to the C/C++ / Command Line page. In the Additional Options box, insert
Code: Select all
/source-charset:utf-8
I have never used this, use it at your own risk.