=?iso-8859-1?q?Re:_const_char_units[]_=_=22=B5A=22;?=
On Aug 6, 3:09 pm, mathieu <mathieu.malate...@gmail.com> wrote:
Sorry if this is slightly off topic. But I have been banging my head
trying to figure out how to solve my issue.
I have a dictionary (simple lookup from a key to string) that in
some case can return a string containing the symbol '=B5'. So my
question is simply, can I write:
const char units[] = "=B5A";
Or will the compilation depend on my computer locale ?
More likely, it will depend on your compiler, perhaps some
compiler options, and perhaps the locale. Or perhaps not.
Formally, what you want is "\u03BCA". In theory, at least, you
should be able to type this in, and get it. Except that in a
lot of cases, there will be no encoding of "\u03BA" in what the
compiler considers its standard "narrow character" encoding;
you'd have to do something like:
wchar_t const units[] = L"\u03BCA" ;
After that, it will depend on what locale is imbued in the wide
stream you write this too.
I'd really appreciate if someone could point me to a presentation of
this issue in C/C++ programming and handling of non-ASCII character.
It's difficult, because so much is implementation dependant.
(Not even necessarily implementation defined---and some of it
goes beyond C++.)
thanks !
-Mathieu
Ps: As a side note can I print this character in most xterm/console ?
#include <iostream>
int main()
{
const char units[] = "=B5A";
std::cout << units << std::endl;
return 0;
}
I can't. To begin with, the machines at work don't even have a
font installed that has a mu character. Which, of course, makes
it very difficult for the compiler to generate code which will
display one.
In general, what the compiler will do when it encounters the mu
character is up to the compiler. I think (but I'm far from
certain) that g++ will simply copy the bytes in a string
constant through; if you can enter the mu character in your
editor (again, I can't), and it looks like a mu, then there's a
chance that the above might work. A chance---no guarantee.
(And of course, if you start the program in a different xterm,
configured to use a font with a different encoding, you'll see
something entirely different.)
--
James Kanze (GABI Software) email:james.kanze:gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34