Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #26167
| From | Joshua Cranmer <Pidgeot18@verizon.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Why No Supplemental Characters In Character Literals? |
| Date | 2011-02-04 08:04 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <iigtgn$ieq$1@news.eternal-september.org> (permalink) |
| References | <iig4k2$sus$1@lust.ihug.co.nz> <iig6j2$dul$2@news.albasani.net> <iig84e$uqu$1@lust.ihug.co.nz> |
On 02/04/2011 01:59 AM, Lawrence D'Oliveiro wrote: > In message<iig6j2$dul$2@news.albasani.net>, Lew wrote: > >> On 02/04/2011 12:59 AM, Lawrence D'Oliveiro wrote: >> >>> Why was it decreed in the language spec that characters beyond U+FFFF are >>> not allowed in character literals, when they are allowed everywhere else >>> (in string literals, in the program text, in character and string values >>> etc)? >> >> Because a 'char' type holds only 16 bits. > > No it doesn’t. Otherwise you wouldn’t be allowed supplementary characters in > character and string values. Which you are. The JLS clearly states that a char is an unsigned 16-bit value. Non-BMP Unicode characters cannot fit in a single unsigned 16-bit value. Where other literals compile down, you can use these non-BMP characters because, e.g., Strings are not individual 16-bit values but an array of them, and can thus safely hold a pair of them. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar
Re: Why No Supplemental Characters In Character Literals? Lew <noone@lewscanon.com> - 2011-02-04 01:34 -0500 Re: Why No Supplemental Characters In Character Literals? markspace <nospam@nowhere.com> - 2011-02-04 11:04 -0800 Re: Why No Supplemental Characters In Character Literals? Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-02-04 08:04 -0500
csiph-web