java - dis.readchar Chinese letters - wrongly interpreted Characters! -
i want read file arraylist of characters. @ first thought might pretty slick way doing it:
arraylist<character> char_chain = new arraylist<character>(); try { fis = new fileinputstream(file); bis = new bufferedinputstream(fis); dis = new datainputstream(bis); while (dis.available() != 0) { // utf8 unnoetig, da 26 lettern while (!eof) { try { char_chain.add(dis.readchar()); } catch (eofexception e) { eof = true; } } } if (debug) { while (char_chain.get(i) instanceof character) { system.out.println(char_chain.get(i++)); } }
if chinese letters:
噖 䝃 塘 䕅
could tell me why is? :) should mention text contains regular upper-case letters like: abcde , on.
datainputstream.readchar()
assumes reading utf-16 characters.
to read character data, use inputstreamreader
correct encoding ("us-ascii" should sufficient if file contains basic latin letters).
Comments
Post a Comment