X
X_AWemner_X
Ok, here is a teaser for all java io coders. Make us all happy and create a
filterreader with proper unicode bom support.
As you know, _we_ have tell InputStreamReader what unicode charset to use
for read operations. (UTF-8, UTF-16, ....). Reader does support BOM mark for
UTF-16 keyword and skip first bytes, but still we must tell it to use
UTF-16. but fails with UTF-8 files.
Win2k Notepad stores BOM mark at the start of UTF-8 files, and currently ISR
cannot read it properly.
http://www.unicode.org/unicode/faq/utf_bom.html#22
Now, do you have a streamreader which support BOMs fully transparently,
something like?
String defaultEnc = "UTF-8"; // java default is ISO-8859-1
Reader in = new BestUnicodeTextStreamReader(new
FileInputStream("myfile.txt"), defaultEnc);
-> this class would recognize all BOM marks automatically and used it. If no
BOM were found, then use given defaultEnc value.
I am sure we n00b coders would love to use such reader implementation.
filterreader with proper unicode bom support.
As you know, _we_ have tell InputStreamReader what unicode charset to use
for read operations. (UTF-8, UTF-16, ....). Reader does support BOM mark for
UTF-16 keyword and skip first bytes, but still we must tell it to use
UTF-16. but fails with UTF-8 files.
Win2k Notepad stores BOM mark at the start of UTF-8 files, and currently ISR
cannot read it properly.
http://www.unicode.org/unicode/faq/utf_bom.html#22
Now, do you have a streamreader which support BOMs fully transparently,
something like?
String defaultEnc = "UTF-8"; // java default is ISO-8859-1
Reader in = new BestUnicodeTextStreamReader(new
FileInputStream("myfile.txt"), defaultEnc);
-> this class would recognize all BOM marks automatically and used it. If no
BOM were found, then use given defaultEnc value.
I am sure we n00b coders would love to use such reader implementation.