Re: Unexpected encoding issue with _() macro and UTF-8 source in Unicode build (wxWidgets 3.3.1)
Simon Richter <[email protected]> Sat, 15 Nov 2025 00:47:37 +0900
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
On 11/15/25 00:22, Claudio Fabiano Rossato wrote:
> Is it expected that |_()| still interprets narrow string literals
> according to the system code page (CP1252) instead of UTF-8, even when
> the compiler is set to UTF-8?
The argument to _() is a narrow string literal that is used for the
lookup of the string in the translation database only. In general it is
assumed to be ASCII text only.
If no entry exists in the database, then the context (if any) is
removed, this string is converted to wxString and returned from the
translation function. In Unicode builds, the wxString will consist of
wxUniChar that can then be converted to the currently active locale's
representation.
The entries in the translation database are converted from the codepage
in the translation file to Unicode, then converted to the active locale
on output.
So any non-ASCII characters must be part of the translation. Quite a few
projects use an English “translation” to get Unicode quote marks.
For translated strings, there is no other way -- there isn't even a
guarantee that the file that the translators edit will be UTF-8, e.g. a
Japanese translator might prepare a .po file using SJIS, and
representing diacritics on the input strings would be difficult here.
> In other words: in a Unicode build, is using |wxS()| (or |FromUTF8|) the
> intended and required way when dealing with UTF-8 source files?
In any build, the parameter of _() is a narrow string and the return
value a wxString that can be output, so you never need wxS() or
FromUTF8() for a translated string.
Simon
--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/wx-users/cba6efd9-c868-42e9-a716-4d5b8dd9b57f%40hogyros.de.
OpenPGP_signature.asc
(application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEtjuqOJSXmNjSiX3Tfr04e7CZCBEFAmkXTxkACgkQfr04e7CZ CBGnfAgAnVbDFK7CgQxgpcQTqBkLRRgkNbBoEOHgYw1Z76jCLA119BqDqPCRPd9K FTN5XBUVsplV+JfRxlJm/sGwl5L0Ja3QIlQI9O0fZJaL5estoPg9URRPUghjxAW6 7incnhdJAR4QMIN5wx/JaWI3+mKfrZn1PEcjBBewByeMWzu7EUOog3ybT3pIZW2o ++oC1ata1rmzHBAP5WM1teI5WVMqNfnrjui9GYrzijU5+zMAJ9GUleLnpMK2nA+G 0bslCaPuoR3yBFopcgZ1qY2hzlQsXR1FJRwKhYg1QRTb4zwbqBR/3hCSOtgwPZ5b RJ7scfCLkfxwCujirpvG0/psDG44QA== =mYSN -----END PGP SIGNATURE-----