Shop OBEX P1 Docs P2 Docs Learn Events
UTF-8 support in libraries — Parallax Forums

UTF-8 support in libraries

ersmithersmith Posts: 6,105
edited 2012-05-12 08:30 in Propeller 1
I see that SIDE is getting UTF-8 support now (very cool!). I just wanted to mention here that in order to get "full" UTF-8 support from a propeller program, or indeed a program on the PC, you need to use the C setlocale function:
#include <locale.h>

int main(void)
{
    setlocale(LC_ALL, "");
    ...
}
Without this any wide character or multibyte character functions will work in plain ASCII rather than UTF-8.

Fortunately the way UTF-8 is constructed this won't matter for many programs (it'll "just work" even without the setlocale), but there are a few cases where there is a difference between ASCII and UTF-8. You'll notice it mainly when converting to/from C wide characters (wchar_t), which on the propeller are 32 bits and can hold any Unicode character in a single wchar_t.

Eric

Comments

  • jazzedjazzed Posts: 11,803
    edited 2012-05-12 08:30
    Thanks Eric.

    I'm working with @MacTuxLin to produce a full Simplified Chinese SimpleIDE.

    Other translations can be easily made by users in their system locale name with the QtLinguist tool.
    My second language is Lao (Thai Issan). This gives me an excuse to learn those symbols with my wife.

    Thanks,
    --Steve
Sign In or Register to comment.