Web lists-archives.com

Re: [Mingw-users] putwchar not working




On 8 September 2016 at 01:42, Eli Zaretskii <eliz@xxxxxxx> wrote:
> --text follows this line--
>> Date: Wed, 7 Sep 2016 17:07:27 +0000 (UTC)
>> From: Hisham Sueyllam <sueyllam@xxxxxxxxx>
>>
>> I tried both Suggestions [the one from Wu and this one suggested by Eli]. Nothing worked at least for Arabic,
>> including piping through perl. By redirecting the Arabic output to a file I can open it and see it correct using any
>> editor [I used emacs], but when piping through perl I get garbage or using puts or putchar or whatever. I have
>> Windows 10 64-bit and gcc 5.3.0 (the latest)
>> By the way if anyone is curious, the Arabic string is my first name:
>>
>> #include <stdio.h>
>>
>> int main() {
>> puts(u8"هشام\n");
>> return 0;
>> }
>
> Your email is encoded in UTF-8, and you use Emacs, so I strongly
> suspect the Arabic string in your source file was also encoded in
> UTF-8.  That will never work; you need to encode it in your system's
> ANSI codepage, I think.  Windows includes only a very sporadic support
> for UTF-8, and in particular cannot use it in multibyte strings.

The problem is that GCC treats the file source as UTF-8, but the puts
function can accept only an ‘ANSI’ string. The conclusion is the same
as yours: removing ‘u8’ and saving the file as the ‘ANSI’ code page
should work.

As discussed earlier, putws does not work. Otherwise, putws(L"هشام\n")
is the logical solution on Windows.

-- 
Yongwei Wu
URL: http://wyw.dcweb.cn/

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe