NO

Author Topic: Does Pelles C supports UNICODE?  (Read 3488 times)

r7u

  • Guest
Does Pelles C supports UNICODE?
« 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?

Code: [Select]
#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;
}

« Last Edit: January 28, 2014, 05:04:54 PM by r7u »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Does Pelles C supports UNICODE?
« Reply #1 on: January 28, 2014, 10:07:10 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
Code: [Select]
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 ?)
May the source be with you

r7u

  • Guest
Re: Does Pelles C supports UNICODE?
« Reply #2 on: January 30, 2014, 01:02:20 PM »
PellesC follows C99 standard, so
Code: [Select]
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.

Code: [Select]
#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:굇


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Does Pelles C supports UNICODE?
« Reply #3 on: January 30, 2014, 02:37:58 PM »
Code: [Select]
_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
Code: [Select]
Terminal font
C:\code1\gcc>a
aa 03B1h

Lucida Console font
C:\code1\gcc>a
αα 03B1h
unicode table here
« Last Edit: January 30, 2014, 04:04:59 PM by timovjl »
May the source be with you