Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Stephen Sprunk <stephen@sprunk.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: wchar_t: signed or unsigned? |
| Date | 2014-04-22 10:48 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <lj6313$d2i$1@dont-email.me> (permalink) |
| References | <4cial9tecgiks7ov2q3c1oo53492kvf3ti@4ax.com> <978c9431-6725-4fd0-83ca-8f426b94de8d@googlegroups.com> |
On 22-Apr-14 05:21, Malcolm McLean wrote: > On Monday, April 21, 2014 5:55:52 PM UTC+1, DSF wrote: >> Hello, group! >> >> Is wchar_t signed or unsigned? Is it different in C++ than in C? >> Or is it one of those things left up to the compiler writer? >> >> I need to know because I'm dealing with an array of chars, but >> they are treated by the outside world as ints. EOFs and error >> codes are expressed in negative values. So I am using unsigned >> chars for the array to avoid the possibility of one of the array >> members being > 127 and being sign extended to a negative int. >> >> I also have an array of wchar_t for dealing with Windows 16-bit >> Unicode. I don't know if Unicode utilizes the fifteenth bit, but >> I don't want to take any chances. In my compiler, wchar_t is >> defined as "unsigned short" so I don't expect any problems. But >> I'd like to know the official word on it. I did Google the >> question, but found page after page espousing which form of Unicode >> is best. Interesting reading, but not an answer. > > It depends how portable you need to be. Please don't encourage sloppy coding. > 16 bits aren't enough to encode all the glyphs in every language in > the world, so if you must support all of Unicode, you can't use > Windows wchar_t at all. However the higher Unicode numbers are used > for pretty marginal alphabets, 15 bits is enough for most purposes. OTOH, there are many CJK ideographs outside the BMP, and the Chinese govt specifically tests for handling of such characters; fail that test and you can't legally import your software into one of the largest and fastest growing markets in the world. There are several other ranges outside the BMP as well: 10000 — 1007F Linear B Syllabary 10080 — 100FF Linear B Ideograms 10100 — 1013F Aegean Numbers 10300 — 1032F Old Italic 10330 — 1034F Gothic 10380 — 1039F Ugaritic 10400 — 1044F Deseret 10450 — 1047F Shavian 10480 — 104AF Osmanya 10800 — 1083F Cypriot Syllabary 1D000 — 1D0FF Byzantine Musical Symbols 1D100 — 1D1FF Musical Symbols 1D300 — 1D35F Tai Xuan Jing Symbols 1D400 — 1D7FF Mathematical Alphanumeric Symbols 20000 — 2A6DF CJK Unified Ideographs Extension B 2F800 — 2FA1F CJK Compatibility Ideographs Supplement E0000 — E007F Tags And more are added with each release of the Unicode Standard. > Unicode defines a series of so-called "non-character code points" of > which 0xFFFF is one, You can use these internally, but you can't export > unicode sequences containing these reserved code points. I don't know > if any Windows fonts actually use Unicode characters 0x7FFFF to 0xFFFFF. > Obviously you won't be able to support them if you use bit 15 as an > internal flag. If you appropriate bit 15, you can't use the entire upper half of the BMP (8000-FFFF), as well as the other planes (10000-10FFFF): A000 — A48F Yi Syllables A490 — A4CF Yi Radicals AC00 — D7AF Hangul Syllables D800 — DB7F High Surrogates DB80 — DBFF High Private Use Surrogates DC00 — DFFF Low Surrogates E000 — F8FF Private Use Area F900 — FAFF CJK Compatibility Ideographs FB00 — FB4F Alphabetic Presentation Forms FB50 — FDFF Arabic Presentation Forms-A FE00 — FE0F Variation Selectors FE20 — FE2F Combining Half Marks FE30 — FE4F CJK Compatibility Forms FE50 — FE6F Small Form Variants FE70 — FEFF Arabic Presentation Forms-B FF00 — FFEF Halfwidth and Fullwidth Forms FFF0 — FFFF Specials S -- Stephen Sprunk "God does not play dice." --Albert Einstein CCIE #3723 "God is an inveterate gambler, and He throws the K5SSS dice at every possible opportunity." --Stephen Hawking
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
wchar_t: signed or unsigned? DSF <notavalid@address.here> - 2014-04-21 12:55 -0400
Re: wchar_t: signed or unsigned? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2014-04-21 20:02 +0200
Re: wchar_t: signed or unsigned? Seungbeom Kim <musiphil@bawi.org> - 2014-04-21 11:07 -0700
Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-21 11:24 -0700
Re: wchar_t: signed or unsigned? Seungbeom Kim <musiphil@bawi.org> - 2014-04-21 11:57 -0700
Re: wchar_t: signed or unsigned? James Kuyper <jameskuyper@verizon.net> - 2014-04-21 15:13 -0400
Re: wchar_t: signed or unsigned? James Kuyper <jameskuyper@verizon.net> - 2014-04-21 14:31 -0400
Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-21 15:28 -0500
Re: wchar_t: signed or unsigned? James Kuyper <jameskuyper@verizon.net> - 2014-04-21 16:48 -0400
Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-21 14:08 -0700
Re: wchar_t: signed or unsigned? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-22 03:21 -0700
Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-22 10:48 -0500
Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-22 09:10 -0700
Re: wchar_t: signed or unsigned? gordonb.8ql82@burditt.org (Gordon Burditt) - 2014-04-23 03:31 -0500
Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-25 10:00 -0500
Re: wchar_t: signed or unsigned? Keith Thompson <kst-u@mib.org> - 2014-04-25 09:00 -0700
Re: wchar_t: signed or unsigned? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-25 10:27 -0700
Re: wchar_t: signed or unsigned? Stephen Sprunk <stephen@sprunk.org> - 2014-04-25 16:43 -0500
csiph-web