On 18 Oct 2005 11:10:25 -0700, "mlimber" <ml*****@gmail.com> wrote:
jalkadir wrote: Can someone please explain to me why, if I type 'Ni(ALT-164)A' at the
windows prompt, I get '[c:\]Niña', but if my program does this:
int main(){
std::string str("Niña");
std::cout << str << std::endl;
return 0;
}
I get [C:\]Ni±a
Can someone please, please, give me a hand understanding this
problem?!!
TIA
Perhaps different fonts are being used in the two windows?
Cheers! --M
This is *Off-Topic*, as it is os-dependent, but the answer follows,
hope it helps.
I deduce from what you write that you are programming in MSWindows.
You are writing the program in some windows-based IDE, where the
charcater set is unicode and/or Windows-1252. In it, 'ñ' has the code
\xf1 and 'Ñ' has the code \xd1.
When you open a console, the character set is another really
different: it is the one that IBM devised for PC some decades ago, and
it is named somethiong like ASSCVII code page 437. In it, the codes
for 'ñ' and 'Ñ' are \xa4 and \xa5, respectively. This characetr set
may be seen at Start | All programs | Accessories | System tools |
Character set, and selecting Terminal font. Well, the exact location
and name of the tool may be slightly different, I am translating form
spanish.
So, you must use some especial means to convert from one code to the
other: either write the characters by escap seuqences, or use the MS
functions CharToOem and CharToOemBuff (serach at msdn.microsoft.com)
Saludos,
Zara