mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "罗勇刚(Yonggang Luo) " <luoyonggang@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com, James McNellis <james@jamesmcnellis.com>,
	 austin-group-l@opengroup.org, Clang Dev <cfe-dev@cs.uiuc.edu>,
	blees@dcon.de,  dplakosh@cert.org, hsutter@microsoft.com,
	writeonce@midipix.org
Subject: Re: Is that getting wchar_t to be 32bit on win32 a good idea for compatible with Unix world by implement posix layer on win32 API?
Date: Sat, 9 May 2015 11:36:44 +0800	[thread overview]
Message-ID: <CAE2XoE8cpsDB5m7bxjO7fKcB9yymDnKnRt3bmOZ4S6kWtfHiwg@mail.gmail.com> (raw)
In-Reply-To: <20150509033232.GG17573@brightrain.aerifal.cx>

2015-05-09 11:32 GMT+08:00 Rich Felker <dalias@libc.org>:
> On Sat, May 09, 2015 at 11:16:37AM +0800, 罗勇刚(Yonggang Luo)  wrote:
>> Two solution:
>> 1、Change the width of wchar_t to 16 bit, I guess that would broken a
>> lot of things that exist on Win32 world.
>> 2、Or we should preserve wchar_t to be 16 bit on win32, and add the
>> char16_t and char32_t
>> variant API for all API that have both narrow and wide version?
>>
>>
>> I support for the second one, even if the second option is not
>> applicable. the first option would cause a lot problems, the first
>> thing is all Windows API use wchar_t and dependent on the wchar_t to
>> be 2 byte width.  Second is, there is open source libraries that
>> dependent the de fac·to that wchar_t to be 16 bit, such as Qt,
>> Git(maybe).
>> Almost exist open source libraries that already ported to Win32 are
>> dependent the the fact wchar_t to be 16 bit,  cygwin is also discussed
>> if getting wchar_t to be 32bit on win32
>>
>> https://www.cygwin.com/ml/cygwin/2011-02/msg00037.html
>
> Well, which option is an easier path forward depends on your main
> usage case. If you're most concerned about building existing
> Windows-targetted code unmodified, obviously doing the same thing MSVC
> does, even if it's a bad design, achieves that.
>
> On the other hand, if your goal is building software that was written
> for POSIX or POSIX-like systems on Windows with little or no
> modification, it's more complicated. Code that currently has no
> Windows support certainly will work best (full Unicode support) with
> 32-bit wchar_t. Code that already has Windows-specific workarounds
> (assuming wchar_t is 16-bit on Windows) needs those undone to make it
> work. But such code _should_ be checking WCHAR_MAX instead of assuming
> Windows is 16-bit. I believe midipix is dealing with this issue simply
> by not predefining _WIN32 or whatever, so that none of the Windows
> workarounds will get activated.
>
> I really suspect most Windows code interfacing with WINAPI is using
> WCHAR, not wchar_t, for its UTF-16 strings. So fixing wchar_t to be
This is a misunderstanding,
The real definition of WCHAR is in winnt.h, and defined as follow:

#ifndef _MAC
typedef wchar_t WCHAR;    // wc,   16-bit UNICODE character
#else
// some Macintosh compilers don't define wchar_t in a convenient
location, or define it as a char
typedef unsigned short WCHAR;    // wc,   16-bit UNICODE character
#endif



> 32-bit and leaving WCHAR alone is the best solution in my opinion.
> Note that you're still left with the issue that L"xxx" strings will
> not work with WCHAR, but this really only matters if you're trying to
> use existing Windows-targetted code unmodified, and it's easily fixed
> by s/L"/u"/g across the source (making them char16_t[] literals rather
> than wchar_t[] literals).
>
> I don't think adding lots of functions for char16_t and char32_t is
> useful. The format you want programs to be using is UTF-8. With
> midipix all of the standard C functions, just like in straight musl,
> always work in UTF-8, and there are also wrappers for the WINAPI that
> convert UTF-8 to UTF-16 transparently. This allows you to just work in
> char[] strings and pass them to WINAPI functions like you would if you
> were working in "ANSI codepage" mode, except that you actually have
> full Unicode available. I strongly support this approach and hope
> you'll adopt it.
>
> Rich



-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo


  reply	other threads:[~2015-05-09  3:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-09  3:16 罗勇刚(Yonggang Luo) 
2015-05-09  3:32 ` Rich Felker
2015-05-09  3:36   ` 罗勇刚(Yonggang Luo)  [this message]
     [not found] ` <CAE2XoE_vO83dVqmJ3xRb9md8H=EO0j723Ycwqijo1To88iGueA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-09  7:55   ` John Sully
2015-05-09 10:36     ` [cfe-dev] " Szabolcs Nagy
     [not found]       ` <20150509103645.GG29035-4P1ElwuDYu6sTnJN9+BGXg@public.gmane.org>
2015-05-09 11:19         ` 罗勇刚(Yonggang Luo) 
2015-05-09 20:05           ` Rich Felker
2015-05-10 12:19             ` 罗勇刚(Yonggang Luo) 
2015-05-10 12:31             ` 罗勇刚(Yonggang Luo) 
2015-05-10 13:42               ` Rich Felker
     [not found]                 ` <20150510134230.GN17573-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2015-05-10 14:15                   ` [musl] " 罗勇刚(Yonggang Luo) 
2015-05-10 15:30                     ` Rich Felker
     [not found]               ` <CAE2XoE8ARm6BkarKYspPK_uDkePw8PewHXPWRXmT+mGM5mwEaw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-11  1:47                 ` [musl] " Mike Frysinger
2015-05-11  3:25                   ` 罗勇刚(Yonggang Luo) 
2015-05-11 10:27                   ` [musl] " Joerg Schilling
2015-05-12  3:21                     ` 罗勇刚(Yonggang Luo) 
2015-05-10 18:47 ` Karsten Blees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE2XoE8cpsDB5m7bxjO7fKcB9yymDnKnRt3bmOZ4S6kWtfHiwg@mail.gmail.com \
    --to=luoyonggang@gmail.com \
    --cc=austin-group-l@opengroup.org \
    --cc=blees@dcon.de \
    --cc=cfe-dev@cs.uiuc.edu \
    --cc=dalias@libc.org \
    --cc=dplakosh@cert.org \
    --cc=hsutter@microsoft.com \
    --cc=james@jamesmcnellis.com \
    --cc=musl@lists.openwall.com \
    --cc=writeonce@midipix.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).