Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Is wchar_t really useful? |
| Date | 2015-11-13 13:36 -0500 |
| Organization | Self |
| Message-ID | <56462D90.2070503@verizon.net> (permalink) |
| References | (2 earlier) <n227bt$q5b$1@solani.org> <n229li$hvg$1@dont-email.me> <n22c4n$bjr$1@solani.org> <n22ekd$7og$1@dont-email.me> <n252vq$4jg$1@solani.org> |
On 11/13/2015 11:26 AM, Philipp Klaus Krause wrote:
> On 12.11.2015 17:29, James Kuyper wrote:
>> On 11/12/2015 10:44 AM, Philipp Klaus Krause wrote:
>>> On 12.11.2015 16:04, James Kuyper wrote:
>>>
>>>> Why exactly are you interested in how an implementation could weasel out
>>>> of this requirement? As I understand it, there's a simple process that
>>>> goes on when designing this part of an implementation of C: choose what
>>>> extended character sets you want to support, and which encoding. Then
>>>> choose a single character encoding capable of representing all of those
>>>> characters, and define wchar_t to be a type big enough to store the
>>>> representations of any of those characters. Did you have a different
>>>> implementation design process in mind?
>>>>
>>>
>>> 1) AFAIK, Windows compilers tend to use a 16-bit wchar_t, and assume
>>> sequences of wchar_t to be UTF-16-encoded. Thus there are characters
>>> that don't fit into a wchar_t. How do these implementations get around
>>> the sandard requirement?
>>
>> I've no idea - possibly by not conforming to the requirements?
>
> So there are no standard-conforming C implementations targeting Windows?
You might be right about that, for all I know - I know more about what
the standard requires for implementations of C, than I do about what
actual C implementations actually do; and I'm even less of an expert in
that regard for Windows platforms.
However, your conclusion above doesn't follow from the information given
below. You can have an implementation of C targeting windows that
implements wchar_t differently from the way Microsoft's compiler does.
> Microsoft documetnation, e.g.
> https://msdn.microsoft.com/de-de/library/yeby3zcb.aspx explicitly says
> that wchar_t uses UTF-8. But that means there are characters that do not
It's been about 30 years since I studied German, and my German was never
good enough to read a document like this, anyway. Giving that URL to
translate.google.com produces a document in a language that resembles
English sufficiently well that I can get some idea of what's going on.
In order to enable this feature, it seems to be necessary to open the
file as follows:
FILE * fp = fopen ("newfile.txt", "RT +, ccs = Encoding");
According to the C standard,
"The argument mode points to a string. If the string is one of the
following, the file is open in the indicated mode. Otherwise, the
behavior is undefined.271)
r open text file for reading
w truncate to zero length or create text file for writing
wx create text file for writing
a append; open or create text file for writing at end-of-file
rb open binary file for reading
wb truncate to zero length or create binary file for writing
wbx create binary file for writing
ab append; open or create binary file for writing at end-of-file
r+ open text file for update (reading and writing)
w+ truncate to zero length or create text file for update
w+x create text file for update
a+ append; open or create text file for update, writing at end-of-file
r+b or rb+ open binary file for update (reading and writing)
w+b or wb+ truncate to zero length or create binary file for update
w+bx or wb+x create binary file for update
a+b or ab+ append; open or create binary file for update, writing at
end-of-file" (7.21.5.3p3)
Note, in particular, the complete absence of any string that even
remotely resembles the mode string used in that example. C is a
case-sensitive language, so even the use of "R" rather than "r" would
make the behavior undefined. Therefore, when using such a mode string to
open a file, the behavior is undefined. The standard imposes no
requirements on the behavior of such a program.
> fit into a single wchar_t, which seems to violate the standard requirements.
In particular, the following requirement does NOT apply when the
behavior of the program is undefined:
"wchar_t
"which is an integer type whose range of values can represent distinct
codes for all members of the largest extended character set specified
among the supported locales; the null character shall have the code
value zero." (7.19p2)
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-09 12:02 +0100
Re: Is wchar_t really useful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-09 03:24 -0800
Re: Is wchar_t really useful? Stephen Sprunk <stephen@sprunk.org> - 2015-11-10 18:33 -0600
Re: Is wchar_t really useful? Ian Collins <ian-news@hotmail.com> - 2015-11-11 13:56 +1300
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-09 09:03 -0500
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-12 15:22 +0100
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-12 10:04 -0500
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-12 16:44 +0100
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-12 11:29 -0500
Re: Is wchar_t really useful? supercat@casperkitty.com - 2015-11-12 09:14 -0800
Re: Is wchar_t really useful? Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-14 11:50 -0800
Re: Is wchar_t really useful? supercat@casperkitty.com - 2015-11-15 13:44 -0800
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-15 22:50 +0100
Re: Is wchar_t really useful? supercat@casperkitty.com - 2015-11-15 14:46 -0800
Re: Is wchar_t really useful? raltbos@xs4all.nl (Richard Bos) - 2015-11-17 22:34 +0000
Re: Is wchar_t really useful? Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-16 07:25 -0800
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-13 17:26 +0100
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-13 13:36 -0500
Re: Is wchar_t really useful? Stephen Sprunk <stephen@sprunk.org> - 2015-11-13 16:37 -0600
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-13 17:58 -0500
Re: Is wchar_t really useful? Stephen Sprunk <stephen@sprunk.org> - 2015-11-13 16:01 -0600
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-13 23:36 +0100
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-12 15:28 +0100
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-12 10:26 -0500
Re: Is wchar_t really useful? Stephen Sprunk <stephen@sprunk.org> - 2015-11-12 14:27 -0600
Re: Is wchar_t really useful? Lőrinczy Zsigmond <nospam@for.me> - 2015-11-13 05:02 +0100
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-13 11:52 +0100
Re: Is wchar_t really useful? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-11-13 05:17 -0800
Re: Is wchar_t really useful? Stephen Sprunk <stephen@sprunk.org> - 2015-11-13 12:58 -0600
Re: Is wchar_t really useful? supercat@casperkitty.com - 2015-11-13 11:14 -0800
Re: Is wchar_t really useful? Stephen Sprunk <stephen@sprunk.org> - 2015-11-13 12:45 -0600
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-13 18:24 +0100
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-13 13:55 -0500
Re: Is wchar_t really useful? Philipp Klaus Krause <pkk@spth.de> - 2015-11-13 20:39 +0100
Re: Is wchar_t really useful? James Kuyper <jameskuyper@verizon.net> - 2015-11-13 14:54 -0500
Re: Is wchar_t really useful? Stephen Sprunk <stephen@sprunk.org> - 2015-11-13 17:04 -0600
csiph-web