Encoding - quoted-printable & charset utf-16 how to read

hi,

I have this following Multipart request comes from a system. Our application has to receive this part and process.

=_Part_26425_3101246.1109752031682

Content-Type: text/plain; name=Mojo.txt; charset=utf-16

Content-Transfer-Encoding: quoted-printable

Content-Location: Mojo.txt

=FE=FF=00M=00o=00j=00o

=_Part_襧%B梧

I could able to receive and save the file locally. As it mentioned, it is encoded using "quoted-printable", so I decoded using the following method.

MimeUtility.decode(fInputStream, "quoted-printable");

and can able to decode the file. Once the decode process is done, I need to read the value of the text file. I understand from the headers(charset=utf-16), I assume it is a UTF-16 file, so i reading the text using the following code but getting some extra ? characters in front of the actual text.

BufferedReader bufferedReader =new BufferedReader(new InputStreamReader(fis,"utf-16"));

String nextLine;

while((nextLine = bufferedReader.readLine()) !=null)

{

System.out.println(nextLine);

}

How to read this correctly?.

rgds

-VK Bala Murali-

[1392 byte] By [bharatbalaa] at [2007-10-1 6:48:19]
# 1
"Some" extra characters? If "some" means "two" then perhaps those two characters are the BOM (Byte Order Mark) that is meant to distinguish between UTF-16LE and UTF-16BE.
DrClapa at 2007-7-9 17:14:26 > top of Java-index,Desktop,I18N...
# 2
I think you are correct. The extra characters are ?. How to remove that from the text file, when I try to read the file I should only get the access string. rgds-vk bala murali-
bharatbalaa at 2007-7-9 17:14:26 > top of Java-index,Desktop,I18N...
# 3

Something like:

// delete BOM, if any

if (sb.charAt(0) == '\uFEFF') {

sb.deleteCharAt(0);

}

or

if (str.charAt(0) == '\uFEFF') {

str = str.substring(1);

}

nguyenq87a at 2007-7-9 17:14:26 > top of Java-index,Desktop,I18N...
# 4
Thanks and it works.
bharatbalaa at 2007-7-9 17:14:26 > top of Java-index,Desktop,I18N...