Unicode question

10 views
Skip to first unread message

Gonzalo Garramuño

unread,
Nov 27, 2025, 4:33:22 PMNov 27
to fltkg...@googlegroups.com
Since Matt is our C++ expert and Albretch is our Unicode one.  Is there
a way in FLTK to replace with an FLTK function this outdated code:

#if defined(_WINDOWS)
            //! \bug
            //!
https://social.msdn.microsoft.com/Forums/vstudio/en-US/8f40dcd8-c67f-4eba-9134-a19b9178e481/vs-2015-rc-linker-stdcodecvt-error?forum=vcgeneral
            typedef unsigned int tl_char_t;
#else  // _WINDOWS
            typedef char32_t tl_char_t;
#endif // _WINDOWS

std::wstring_convert<std::codecvt_utf8<tl_char_t>, tl_char_t>
                utf32Convert;

Matthias Melcher

unread,
Nov 28, 2025, 6:03:36 AMNov 28
to fltk.general
`std::wstring_convert` was removed in C++20. FLTK offers a bunch of functions to convert utf8 to Windows utf16 and Unicode ucs4 and back, including Windows utf16.


but more detailed documentation of every call is here:


Coverting from utf8 to ucs4 (32 bit Unicode) is rather uncommon, so FLTK does not have a general function for it. It can however convert individual characters with fl_utf8encode and fl_utf8decode (https://fltk.gitlab.io/fltk/group__fl__unicode.html#gad80ac8abaa3ed7b8c245447d6b3aab95).

The more common case, converting Windows utf16 to utf8 is covered by fl_utf8toUtf16 (https://fltk.gitlab.io/fltk/group__fl__unicode.html#ga6b537f15e29c1eb78bee7c24483dc759), or in a more cross platform way by fl_utf8towc (https://fltk.gitlab.io/fltk/group__fl__unicode.html#gac483f43232e4444086487d3417236209) which converts to wchar_t, which is 16 bits on Windows and 32 bit on all other platforms.

After having rewritten the whole Doxygen comments, I see now the real problem: we never updated the "Unicode and UTF-8 support" page, and it is not very useful as it stands right now.
Reply all
Reply to author
Forward
0 new messages