UTF-8 Build on Windows
UTF-8 Build on Windows
Hi.
To update custom software, I decided to switch form wxWidgets version 2.9.3 to 3.0.4.
I need, contextually, to adopt utf-8 encoding, so, under Linux, configure the '--enable-uft8' parameter and all goes ok.. obtain the follow configuration:
- wxUSE_WCHAR_T=1
- wxUSE_UNICODE=1
- wxUSE_UNICODE_UTF8=1
- wxUSE_UNICODE_WCHAR=0
but under Windows I'm not able to force this configuration.. in poor words I want have the size of 1 byte for single char.. is it possible under Windows? how can I do it?
Thanks at all.
To update custom software, I decided to switch form wxWidgets version 2.9.3 to 3.0.4.
I need, contextually, to adopt utf-8 encoding, so, under Linux, configure the '--enable-uft8' parameter and all goes ok.. obtain the follow configuration:
- wxUSE_WCHAR_T=1
- wxUSE_UNICODE=1
- wxUSE_UNICODE_UTF8=1
- wxUSE_UNICODE_WCHAR=0
but under Windows I'm not able to force this configuration.. in poor words I want have the size of 1 byte for single char.. is it possible under Windows? how can I do it?
Thanks at all.
Re: UTF-8 Build on Windows
Hi,
You don't need this switch as under Linux/GTK everything is UTF-8 by default.
For Windows - which compiler do you use? Which environment?
You don't need a UTF-8 under Windows - if you do, you can just simpoly convert the string with ToUTF8() call.
Thank you.
You don't need this switch as under Linux/GTK everything is UTF-8 by default.
For Windows - which compiler do you use? Which environment?
You don't need a UTF-8 under Windows - if you do, you can just simpoly convert the string with ToUTF8() call.
Thank you.
Re: UTF-8 Build on Windows
Thanks ONEEYEMAN for reply.ONEEYEMAN wrote: ↑Fri Dec 20, 2019 3:34 pmHi,
You don't need this switch as under Linux/GTK everything is UTF-8 by default.
For Windows - which compiler do you use? Which environment?
You don't need a UTF-8 under Windows - if you do, you can just simpoly convert the string with ToUTF8() call.
Thank you.
For Linux, ok.
For Windows, my goal is obtain the relation 1 char = 1 byte, as like as Linux, to avoid communication/connection problems with using my program's pipe and similar.
Must i deduce that, under Windows OS, it will not possible?
Re: UTF-8 Build on Windows
Theoretically it should be possible, but i've never tried it.
Which compiler do you use and how exactly (command line) did you build wxWidgets?
What errors did you get?
Which compiler do you use and how exactly (command line) did you build wxWidgets?
What errors did you get?
Use the source, Luke!
Re: UTF-8 Build on Windows
That is not how UTF-8 works. In UTF-8, 1 char(acter) takes between 1 and 4 bytes. sizeof(char) is not affected by a build, it is always the same, unlike that of wchar_t/wxChar. You must be confusing UTF-8 with the deprecated ANSI (non-Unicode) build where one character takes one byte and it uses code pages to switch between 8-bit character sets?
Anyway, if you really want to try UTF-8 on MSW, read the docs here to see how to build wxWidgets to do that
https://docs.wxwidgets.org/trunk/overvi ... g_internal
I do not think this option is common or well-tested on MSW. I am not even sure how it works when MSW is internally UTF-16 (Win10 introduced UTF-8 locale very recently, btw) but I guess it somehow does, at the expense of converting each and every string during API calls.
EDIT
Sorry, I somewhat managed to miss that you are aware of the build options.
I looked into it a bit:
Using USE_UNICODE_UTF8=1 USE_UNICODE_WCHAR=0 when building with nmake still seems to produce the default wchar_t build. I did not find either of this options mentioned anywhere in setup.h nor the makefile.vc/config.vc files.
CMake (on MSW) does not expose this option at all.
I would ask how one should obtain UTF-8 build on MSW in the wx-users group.
Re: UTF-8 Build on Windows
I created a simple example that create a frame with a status bar in which I wrote a string to view 'special characters' writing and 'wxStringCharType' size.
For wxWidgets I try 2 time:
- 1st with mingw compiler, using the command:
in the makefile I configure SHARED=1 MONOLITHIC=1, and then compile the example with command:mingw32-make -j3 -f makefile.gcc
.mingw32-g++ -o testwx testwx.cpp -IwxWidgets-3.0.4-debug\include -IwxWidgets-3.0.4-debug\lib\gcc_dll\mswud -LwxWidgets-3.0.4-debug\lib\gcc_dll -lwxmsw30ud_gcc_custom
The exe runs and show the frame with correct writing but with a size of 2 bytes;
- 2nd with cl compiler (my program will use VisualStudio library and compiler), so I compile with the commands:
nmake -f makefile.vc SHARED=1 MONOLITHIC=1 BUILD=debug
..but I'm encountering difficult to run the exe..cl /DDEBUG /DWXUSINGDLL /D__WXMSW__ /EHsc testwx.cpp /I..\wxWidgets-3.0.4-debug\include /I..\wxWidgets-3.0.4-debug\lib\vc_dll\mswud /link ..\wxWidgets-3.0.4-debug\lib\vc_dll\*.lib

Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
Before giving good Advice, good Examples must be given.
Re: UTF-8 Build on Windows
Indeed, I have been studying the topic for many days .. probably my bad English leads me not to clearly expose the topic on which, probably, however, I still have some doubtsPB wrote: ↑Mon Dec 23, 2019 11:23 am
That is not how UTF-8 works. In UTF-8, 1 char(acter) takes between 1 and 4 bytes. sizeof(char) is not affected by a build, it is always the same, unlike that of wchar_t/wxChar. You must be confusing UTF-8 with the deprecated ANSI (non-Unicode) build where one character takes one byte and it uses code pages to switch between 8-bit character sets?
Precisely by virtue of this page, which I had already found, I continue to think that there is a possibilityPB wrote: ↑Mon Dec 23, 2019 11:23 amAnyway, if you really want to try UTF-8 on MSW, read the docs here to see how to build wxWidgets to do that
https://docs.wxwidgets.org/trunk/overvi ... g_internal
Thanks for helpPB wrote: ↑Mon Dec 23, 2019 11:23 amI looked into it a bit:
Using USE_UNICODE_UTF8=1 USE_UNICODE_WCHAR=0 when building with nmake still seems to produce the default wchar_t build. I did not find either of this options mentioned anywhere in setup.h nor the makefile.vc/config.vc files.
CMake (on MSW) does not expose this option at all.
I would ask how one should obtain UTF-8 build on MSW in the wx-users group.
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
Before giving good Advice, good Examples must be given.
Re: UTF-8 Build on Windows
As PB already mentioned, you need to rebuild the wxWidgets libraries with wxUSE_UNICODE_UTF8=1
Error descriptions like this are not very useful. What exactly happens?..but I'm encountering difficult to run the exe..
Use the source, Luke!
Re: UTF-8 Build on Windows
Hi,
Keep in mind that 1 char = 1 byte is possible only with old ANSI build.
With UNICODE (and UTF-8) it is not possible. You will not be able to store any of the native letters in the 1 byte.
And of course there should be no issue when you try to communicate *nix <-> Win as the communication library will take care of that and you will send strings anyway. It will just be implementation details.
Thank you.
Keep in mind that 1 char = 1 byte is possible only with old ANSI build.
With UNICODE (and UTF-8) it is not possible. You will not be able to store any of the native letters in the 1 byte.
And of course there should be no issue when you try to communicate *nix <-> Win as the communication library will take care of that and you will send strings anyway. It will just be implementation details.
Thank you.
Re: UTF-8 Build on Windows
Sorry, the cl compile goes ok, but when I try to launch exe. the dialog doesn't appear..
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
Before giving good Advice, good Examples must be given.
Re: UTF-8 Build on Windows
Did you use a debug build and run under a debugger? If there is no crash or assert, there must be another reason if a dialog doesn't show up.
Use the source, Luke!
Re: UTF-8 Build on Windows
Hi,
Are wx dlls accessible for the executable?
Thank you.
Are wx dlls accessible for the executable?
Thank you.
Re: UTF-8 Build on Windows
.. I hadn't thought of that .. I try to look
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
Before giving good Advice, good Examples must be given.
Re: UTF-8 Build on Windows
.. I didn't think of looking at the permissions of the files because I compiled in the same way, from the same shell and with the same user .. I copied the dll by hand to the root of the example.
I just launched a new clean compilation, if it doesn't work I look at it ..
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
Before giving good Advice, good Examples must be given.
Re: UTF-8 Build on Windows
The dll has permissione or read and executeAlSith wrote: ↑Mon Dec 23, 2019 2:19 pm.. I didn't think of looking at the permissions of the files because I compiled in the same way, from the same shell and with the same user .. I copied the dll by hand to the root of the example.
I just launched a new clean compilation, if it doesn't work I look at it ..
Do or Do Not; there is No Try.
Before giving good Advice, good Examples must be given.
Before giving good Advice, good Examples must be given.