J
Jon Skeet [C# MVP]
Branco said:The Windows ANSI encoding (engoding number 1252) usually works for me,
because (AFAIK) it doesn't apply any transformation to the individual
byte, i.e., there's a mapping from each byte value to each ANSI char,
for a total of 256 possible chars (control chars included).
How can you say there isn't any transformation, and then talk about
there being a mapping from each byte value to a character? That *is*
the transformation.
Talking about "the" Windows ANSI Encoding is like talking about "the"
extended ASCII encoding. There are lots of different encodings which
exhibit the same behaviour as 1252, i.e. they have a mapping from any
byte to one of the 256 characters they represent. Each represents a
different set of 256 characters.
This is not the case with the ANSI encoding. In ANSI, each byte value
matches a corresponding char. Of course, if the string you're encoding
contains chars outside the ANSI range, such chars will be
misrepresented. Also, if you read a non-ansi sequence of bytes and
convert them to a string using ANSI, you'll probably get some strange
results.
Exactly - so it's like any other encoding: you've got to make sure you
use the right one.
Code page 1252 has no magic powers.
Jon