Re: Unicode Character not displaying on Dialog Screen
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 26 Nov 2009 14:20:43 -0500
Actually, the Microsoft C compiler can accept in a quoted string any character in the
range of 32-255, and historically every C compiler I have worked with since the 1980s has
worked this way. This includes C compilers from a variety of vendors, on Unix, MS-DOS,
Windows, and several embedded platforms. (Below 32 is dangerous; while the MS compiler
can accept a tab character, I met one C compiler that rejected *any* character code below
32, and we had to use \t, which was always my preference anyway. I have grown to despise
the tab character in my career, and only use it in very limited contexts, usually using it
as a field-delimiting token rather than as something that controls layout. I always,
without exception, turn off tabs in source code and ONLY use spaces for doing layout. Any
source file that passes through my editor is automatically detabified on save)
\u00b0 should work only on L" " or L' ' contexts since it would not be legal in 8-bit
character strings.
The only problem arises when the code page doesn't support the degree symbol in its font,
e.g., MS-DOS vs. Windows code pages (CP_OEM vs. CP_ANSI) but the degree symbol at code
point 0xB0 is the only one listed in Unicode (there are °F and °C in the 2100 area, but
suprisingly, not a °K).
Across dozens of text editors over the years, I've never found one that failed to properly
handle non-7-bit characters in quoted strings. And no C compiler since at least 1983 has
failed to accept these in a quoted string, across a huge number of vendors, included
embedded systems.
joe
On Wed, 25 Nov 2009 19:27:12 +0100, "Giovanni Dicanio"
<giovanniDOTdicanio@xxxxxxxxxxxxxxxxx> wrote:
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> ha scritto nel messaggioJoseph M. Newcomer [MVP]
news:e1pqg5l8ptdce5h5fvsq0d2hnbsmiofte1@xxxxxxxxxx
I would have written
TCHAR ds = _T("°");
and not bothered with the rest of the code, but the extra concatenation is
unnecessary; I
would have written
CString strDegr;
strDegr.Format(_T("%d °"), CD.m_intNormDegree);
note that "degree" is not a "Unicode" character; in the ISO-8859-1
standard it is code
0xB0, which is a valid character in even an 8-bit character string. I was
writing code
like this in 16-bit Windows.
I would not insert non-ASCII characters in C/C++ source codes.
0xB0 has the most significant bit set, it is not a pure-ASCII (I mean: 7-bit
ASCII) character; so I would prefer using the \u00B0 encoding in source
code, instead of directly using ° .
My 2 cents,
Giovanni
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Unicode Character not displaying on Dialog Screen
- From: Tony C .
- Re: Unicode Character not displaying on Dialog Screen
- From: Mikel
- Re: Unicode Character not displaying on Dialog Screen
- From: Giovanni Dicanio
- Unicode Character not displaying on Dialog Screen
- Prev by Date: Re: Unicode Character not displaying on Dialog Screen
- Next by Date: Re: Unicode Character not displaying on Dialog Screen
- Previous by thread: Re: Unicode Character not displaying on Dialog Screen
- Next by thread: Re: Unicode Character not displaying on Dialog Screen
- Index(es):
Relevant Pages
|