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:55 -0500 |
| Organization | Self |
| Message-ID | <5646322F.1050307@verizon.net> (permalink) |
| References | <n1puh2$17n$1@solani.org> <n256d6$hkv$1@solani.org> |
On 11/13/2015 12:24 PM, Philipp Klaus Krause wrote: > Could an implementation decide that characters in the execution > character set are just the values of char? wchar_t could be 8 bits. > The source character set could be utf-8 encoded unicode, and the > characters in the execution character set would be the bytes of the > utf-8 sequence. UTF-8 is fine for the multibyte character encoding, but it doesn't work for wchar_t: "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." (7.19p2) > Would this violate "In a character constant or string literal, members > of the execution character set shall be represented by corresponding > members of the source character set […]" from 5.2.1? > Unfortunately, that would mean that functions like mbrtoc32() couldn't > convert to UTF-32 anymore, since they are supposed to read and interpret > only one multibyte character at a time. How did you reach that conclusion? mbrtoc32() reads multiple characters through it's char* parameter: "If s is not a null pointer, the mbrtoc32 function inspects at most n bytes beginning with the byte pointed to by s to determine the number of bytes needed to complete the next multibyte character (including any shift sequences)." I just noticed that I hadn't paid enough attention to the description of mbrtoc32(). It can also convert a single multibyte input character into multiple char32_t values - you just need to call mbrtoc32() multiple times. It only stores one char32_t value at a time, but if the correct translation results in multiple char32_t values, then "Subsequent calls will store successive wide characters without consuming any additional input until all the characters have been stored." mbrtoc16() has similar wording - so that explains why UTF-16 and UTF-32 are permissible encoding for char16_t and char32_t, respectively. mbrtowc() does not have the wording about "Subsequent calls", which confirms that UTF-like encodings are not permitted for wchar_t.
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