Pelles C forum

Pelles C => General discussions => Topic started by: r7u on January 28, 2014, 04:06:16 PM

Title: Does Pelles C supports UNICODE?
Post by: r7u on January 28, 2014, 04:06:16 PM
This code completely works in GCC with code blocks, it can get the correct output.

But in Pelles C, the output is incorrect, just a "?".

Pelles C supports UTF-16LE source code, so I think the compiler supports UNICODE

But why I cannot get the correct output?

Is this code problem, or the compiler problem?


#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <wchar.h>

int main()
{
    wchar_t* a = L"α";
fflush(stdout);
    _setmode(_fileno(stdout), 0x20000); // set console mode to unicode
    wprintf(L"%s", a);
    return 0;
}

Title: Re: Does Pelles C supports UNICODE?
Post by: TimoVJL on January 28, 2014, 10:07:10 PM
Quote from: r7u on January 28, 2014, 04:06:16 PM
This code completely works in GCC with code blocks, it can get the correct output.

But in Pelles C, the output is incorrect, just a "?".

Pelles C supports UTF-16LE source code, so I think the compiler supports UNICODE

But why I cannot get the correct output?

Is this code problem, or the compiler problem?

PellesC follows C99 standard, so wprintf(L"%ls", a); as a is wchar_t type string.
What gcc gives you correct output and with what font ? (MinGW gcc use msvcrt.dll ?)
Title: Re: Does Pelles C supports UNICODE?
Post by: r7u on January 30, 2014, 01:02:20 PM
Quote from: timovjl on January 28, 2014, 10:07:10 PM
PellesC follows C99 standard, so wprintf(L"%ls", a); as a is wchar_t type string.
What gcc gives you correct output and with what font ? (MinGW gcc use msvcrt.dll ?)



Please try this code, I checked my console's font that is Terminal (Pelle C, incorrect output).

For the GCC, font is also the Terminal, but output is correct.

so I don't think this is the issue.


#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <wchar.h>

int main()
{
    wchar_t* a = L"αα";
    fflush(stdout);
    _setmode(_fileno(stdout), 0x20000); // set console mode to unicode
    wprintf(L"%ls", a);
    return 0;
}




Following is the output in different CJK code page, that means the %ls lets wprintf treat the "a" as two bytes as one character, but it also treat them as ANSI code, not unicode.

950:控
932:アア
949:굇

Title: Re: Does Pelles C supports UNICODE?
Post by: TimoVJL on January 30, 2014, 02:37:58 PM
_setmode(_fileno(stdout), 0x20000); // set console mode to unicodeI think that that line doesn't work in PellesC as _setmode() support only _O_TEXT and _O_BINARY, not that _O_U16TEX as it works in Win 7-> mscvrt.dll and mscvrXX.dll.

I don't have far east Terminal font to test.

Testing in Win7 with gcc and with modified code

Terminal font
C:\code1\gcc>a
aa 03B1h

Lucida Console font
C:\code1\gcc>a
αα 03B1h

unicode table here (http://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF)