This content has been marked as final. Show 6 replies
new String(bytebuffer.array(), "ASCII");
Note that you CAN'T correctly convert a byte array to a String without knowing its encoding. Read [_The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)_|http://www.joelonsoftware.com/articles/Unicode.html] for details.
tonnot wrote:Nope, ANSI is not the same as ASCII.
My file is ANSI coded (pure ascii, isn't it ?)
ANSI is not a well-specified encoding at all, in fact.
Usually "ANSI" is used to refer to "whatever the platform default encoding is on this Windows machine". So if you move a text file in "ANSI" encoding from an english Windows installation to another Windows installation that's set to use a russian locale, then "ANSI" will mean something different on those two machines and therefore the decoded String won'T be correct (unless you're lucky and your file only contains characters from the ASCII-subset (i.e. the lower 128 values)).
On English-language Windows installations, ANSI usually refers to [Windows-1252|http://en.wikipedia.org/wiki/Windows-1252].
tonnot wrote:If I happen to have the same locale setting as you and open it in notepad, I'll see the ñ.
in a simple file written with notepad and ANSI write option ....
if I write ñ ( the spanish n with upper sign) and give you the file... what do you see ?
If I have any other setting, I'll see another character that's got the same numeric value in the encoding of my locale.
If you also tell me the real encoding (for example windows-1252) and I use that information to load the file with a sane program (i.e. one that actually knows and cares about encoding), then I'll see the ñ.