wxFormBuilder and special charsets

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
mrdebug
Earned some good credits
Earned some good credits
Posts: 131
Joined: Mon Jul 17, 2006 4:57 pm

wxFormBuilder and special charsets

Post by mrdebug » Wed Jan 23, 2019 2:46 pm

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?

Kvaz1r
Earned some good credits
Earned some good credits
Posts: 119
Joined: Tue Jun 07, 2016 1:07 pm

Re: wxFormBuilder and special charsets

Post by Kvaz1r » Wed Jan 23, 2019 3:32 pm

mrdebug wrote:If I write "Modalità di pagamento" as label in wxFormBuilder, the software will display the label erroneously.
Which OS and version of wxFormBuilder do you use? I can't reproduce problem on Win7 with wxFB v3.9.0.

But better create a new issue in their repo - https://github.com/wxFormBuilder/wxFormBuilder

mrdebug
Earned some good credits
Earned some good credits
Posts: 131
Joined: Mon Jul 17, 2006 4:57 pm

Re: wxFormBuilder and special charsets

Post by mrdebug » Wed Jan 23, 2019 4:05 pm

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"?

Manolo
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 690
Joined: Mon Apr 30, 2012 11:07 pm

Re: wxFormBuilder and special charsets

Post by Manolo » Wed Jan 23, 2019 4:09 pm

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

mrdebug
Earned some good credits
Earned some good credits
Posts: 131
Joined: Mon Jul 17, 2006 4:57 pm

Re: wxFormBuilder and special charsets

Post by mrdebug » Wed Jan 23, 2019 4:21 pm

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?
Image

mrdebug
Earned some good credits
Earned some good credits
Posts: 131
Joined: Mon Jul 17, 2006 4:57 pm

Re: wxFormBuilder and special charsets

Post by mrdebug » Wed Jan 23, 2019 4:46 pm

The only way seems to insert the text of the labels by hand like this

label01->SetLabel(wxT("Modalit\u00E0 di pagamento"))

Kvaz1r
Earned some good credits
Earned some good credits
Posts: 119
Joined: Tue Jun 07, 2016 1:07 pm

Re: wxFormBuilder and special charsets

Post by Kvaz1r » Wed Jan 23, 2019 5:16 pm

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"?
Never heard about such problem and code below work for me:

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);
It's not seems like wxFormBuilder problem, do you build wxWidgets in unicode mode? Btw, which version of the library do you use?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2007
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxFormBuilder and special charsets

Post by PB » Wed Jan 23, 2019 5:20 pm

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.
wxfbencoding.png
wxfbencoding.png (22.15 KiB) Viewed 305 times
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...

mrdebug
Earned some good credits
Earned some good credits
Posts: 131
Joined: Mon Jul 17, 2006 4:57 pm

Re: wxFormBuilder and special charsets

Post by mrdebug » Wed Jan 23, 2019 8:09 pm

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?

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2007
Joined: Sun Jan 03, 2010 5:45 pm

Re: wxFormBuilder and special charsets

Post by PB » Wed Jan 23, 2019 8:41 pm

mrdebug wrote:Is it a wxWidgets bug?
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.

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 
The above obviously needs to be done for all configurations (Debug, Release, ...) you are going to use.

I have never used this, use it at your own risk.

Post Reply