Encoding.UTF8.GetString behaviour

  • Thread starter Thread starter Carl
  • Start date Start date
C

Carl

Hi,

The problem I am having is with chart 2 ASCII character codes, 128 and
greater). The following line makes chars 128 in a byte array and greater
vanish or turn into squares in the string:

string str = Encoding.UTF8.GetString (bytes, 0, byte.Length-1);

Any suggestions appreciated,
Carl.
 
There's been some discussion on encoding lately, not really sure if it was
on this ng, but this link was suggested as a good starting point for
encoding - http://www.joelonsoftware.com/articles/Unicode.html

Not sure exactly what you're problem is, but I have one too :)

For the life of me, I can't print to a text file the characters that I would
expect. For example, I'd like dec 255 to show up as a FF - a little y with
dots.

With the CF, I can loop through the array of bytes and char() them. When
displayed in a text box, things are fine. But whenever I shoot it to a text
file, I can't seem to read it properly.

Now that I think about it, I use UltraEdit for my text/hex editor. Need to
find my copy of HexEdit. I know for a fact that UltraEdit used to have a bug
that 0D0D0A showed up as 0D0A. Nasty little thing that was.

Cheers,
Mike
 
Looks like I need to get the encoding for a given code page beforehand:

Encoding enc = Encoding.GetEncoding(1252);
 
Back
Top