Re: Unicode Character not displaying on Dialog Screen

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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 messaggio
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

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: A note on computing thugs and coding bums
    ... It would handle international characters if the execution character ... method I used in "Build Your Own .Net Language and Compiler". ... work areas and counting on Nul is an illusion. ...
    (comp.programming)
  • Re: PL/I string representations
    ... >> of the language, so it was interesting to me, hopefully it will be to ... I found a workable compiler for Fortran in 1971 (with a bug ... >> The specified length is the minimum, and each time a character ... >> string is assigned to E, the length is stored with it. ...
    (comp.programming)
  • Re: weird I/O problem with g77
    ... You are formatting an integer with a character edit descriptor. ... unlikely to be the only compiler for which this causes odd / unexpected ... > The g77 compiler on both Cygwin and RH Linux systems produced the ... I checked the F77 standard ...
    (comp.lang.fortran)
  • Re: The #include directive
    ... I've immediately thought of OpenVMS when reading this. ... You'd instruct the compiler to look for included files ... The oddity came up when foo.h contained #include bar.h. ... contains a "/" character that is not the first character and is ...
    (comp.lang.c)
  • Re: To "TAB" or not to "TAB"
    ... > negative I want etc. in character strings now in every compiler I'm ... If there is a graphic character in the string, ... that you are saying that the compiler should do no special processing, ...
    (comp.lang.fortran)