Topic: Which one is correct?


Author: maximus@microsoft.com ("Maximus")
Date: Tue, 12 Jun 2007 19:40:34 GMT
Raw View
wchar_t ch2 = L'\u27BA';
wchar_t ch = '\u27BA';

On Visual C++ 2003 SP1, no compiler warnings are given at all. However, ch
!= ch2.

Which one is correct?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Mathias Gaunard <loufoque@gmail.com>
Date: Wed, 13 Jun 2007 10:46:44 CST
Raw View
On Jun 12, 9:40 pm, maxi...@microsoft.com ("Maximus") wrote:
> wchar_t ch2 = L'\u27BA';
> wchar_t ch = '\u27BA';
>
> On Visual C++ 2003 SP1, no compiler warnings are given at all. However, ch
> != ch2.
>
> Which one is correct?

27BA is 10170.
'\u27BA' being of type char, it can't be greater than 255, assuming 8-
bit bytes. So it can't contain 10170.
L'\u27BA' being of type whar_t, which is on all implementations I know
at least 16 bits, it can contain 10170.

Therefore the correct one is the first one.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: ron@spamcop.net (Ron Natalie)
Date: Thu, 14 Jun 2007 15:33:15 GMT
Raw View
Mathias Gaunard wrote:
> On Jun 12, 9:40 pm, maxi...@microsoft.com ("Maximus") wrote:
>> wchar_t ch2 = L'\u27BA';
>> wchar_t ch = '\u27BA';
>>
>> On Visual C++ 2003 SP1, no compiler warnings are given at all. However, ch
>> != ch2.
>>
>> Which one is correct?
>
> 27BA is 10170.
> '\u27BA' being of type char, it can't be greater than 255, assuming 8-
> bit bytes. So it can't contain 10170.

Nothing says that \uXXXX maps directly into a character value.   The
number after the u is an ISO 10646 (practically unicode) value.   Do
not assume the execution character set is ASCII.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]