What is the legal range of chars?

Jonathan M Davis jmdavisProg at gmx.com
Wed Jun 19 13:09:38 PDT 2013


On Wednesday, June 19, 2013 21:22:00 monarch_dodra wrote:
> Well, there is still ambiguity when you have a standalone char if
> it is holding a (paritally truncated) code unit, or a partial
> code point.
> 
> If I write:
> char c = '\xDF'; //0b11011111; //Lead UTF-8 2 byte encoding
> wchar w = 'ß'; //0b11011111; \u00DF
> assert(c == w);
> 
> The assert passes. Yet 'c' is just the partial of a 2 byte
> sequence, and not 'ß'.

Well, it's fundamentally broken to compare char and wchar unless you know that 
both of the values being compared are ASCII values. They're different 
encodings.

> In any case, this conversation gave me the answers I was looking
> for in the context of the original question.

Good to hear.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list