Saturday, 15 August 2015

Does Java read 0xA0 as 0xFFFD -



Does Java read 0xA0 as 0xFFFD -

one of info processing modules crashed while reading ansi input. looking @ string in question using hex viewer, there mysterious 0xa0 byte @ end of it.

turns out non-breaking space.

i tried replacing that:

string s = s.replace("\u00a0", "");

but didn't work.

i went , printed out character using charat , java reports

65533

or 0xfffd

plugging replace code, got rid of it!

but why see 0xa0 in file, java reads 0xfffd?

bufferedreader r = new bufferedreader(new inputstreamreader(new fileinputstream(path), "utf-8")); string line = r.readline(); while (line != null){ // stuff line = r.readline(); }

u+fffd "unicode replacement character", used represent "some binary info couldn't decoded correctly in encoding using". (sometimes ? used instead, u+fffd improve idea, it's unambiguous.)

its presence sign you've tried utilize wrong encoding. haven't specified encoding were using - or indeed how using - that's problem. check encoding you're using , encoding of file. aware "ansi" isn't encoding - there lots of encodings known ansi encodings, , you'll need pick right 1 file.

java

No comments:

Post a Comment