Encoding issues with literal strings (C++)
- From: Carlos Moreno <moreno_at_mochima_dot_com@xxxxxxxxxxxxxx>
- Date: Wed, 20 Dec 2006 11:34:03 -0500
Hi,
I'm a bit puzzled by the following.
My application is a client/server, where the server runs on Linux
and is written in C++. The client runs on Windows and is written
in Borland C++ Builder 6.
Since it is in Spanish (most of the users are hispanophones), I
have many messages that the server sends that include characters
with accent (in HTML, á é , etc.).
Some of these messages come from literal strings, with embedded
\x sequences to represent the special characters in ISO-8859-1
(or rather, Windows-1252).
For instance, in LATIN1 (ISO-8859-1) and in Windows-1252 encodings,
the a with acute accent has the code 0xE1; the o with acute accent
has code 0xF3 ... So I write those just like that (well, \xE1 and
\xF3 in the literal strings), and it works.
But I have two puzzling problems:
1) When I write the i with acute accent (which has code 0xED), that
one doesn't work (shows up as a greek letter beta on the client,
and the letter after that one doesn't show).
When I do a hexdump -C of the executable, I see that the string
is not the same!!! The \xED character has been replaced by a
0xDF, and the character after the \xED is missing !!! Here:
The literal string is: " ..... espec\xEDficos ..... "
The hexdump output (the relevant line) is:
65 73 20 65 73 70 65 63 df 69 63 6f 73 2e 20 20 |es espec.icos. |
Why did that happen? How do I avoid it? --- without having to
manually edit the executable, that is). I have the feeling that
it has to do with UTF-8 encoding, perhaps invalid UTF-8 sequences
that the compiler is "fixing" --- but, if that is the case, why?
2) The other thing is that I'm getting a compiler warning of hex
escape sequence out of range for the \xF3 --- yet that character
shows up ok (the o with acute accent).
Thanks for any ideas!
Carlos
--
.
- Follow-Ups:
- Re: Encoding issues with literal strings (C++)
- From: jasen
- Re: Encoding issues with literal strings (C++)
- From: John Fusco
- Re: Encoding issues with literal strings (C++)
- Prev by Date: Re: typedef forward declare
- Next by Date: Re: Encoding issues with literal strings (C++)
- Previous by thread: about control the cdrom drive
- Next by thread: Re: Encoding issues with literal strings (C++)
- Index(es):
Relevant Pages
|