由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - A question about Content-type & encoding
相关主题
显示email中文的问题我脑袋短路,大家来帮一下:
SpringMVC可否直接处理doGet?Spring JDBC无法正确插入blob到MySQL
请教汉字的utf-8 mapping (转载)getBytes() 卡住了 求助
遇到一个程序运行错误火车旅行家在中文WINDOWS下无法运行的大问题已被解决
怎麼得到字符串中的raw bytes?Re: 问题:用Java/HTTP协议传送jpg图像文件
问个xml的问题由一个Java Bug谈起
一个想不明白的编码问题[转载] java sex package
请教个html显示utf8 string的问题 (转载) Documentum DFC
相关话题的讨论汇总
话题: content话题: unknown话题: type话题: charset话题: multipart
进入Java版参与讨论
1 (共1页)
c*y
发帖数: 137
1
I am writing an email client. There are several lines like this in the program:
message.getContent()
Then for one email I got an exception which will abort the operation, the exception
is:
java.io.UnsupportedEncodingException: X-UNKNOWN
I looked at the email mesage, and found out in the headers of the email:
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN
obviously it was the charset's problem..
How can solve this problem?
Thanks.
g****y
发帖数: 141
2
what is in that email?
guess u must have ur program support X-UNKNOWN...

program:
exception

【在 c*y 的大作中提到】
: I am writing an email client. There are several lines like this in the program:
: message.getContent()
: Then for one email I got an exception which will abort the operation, the exception
: is:
: java.io.UnsupportedEncodingException: X-UNKNOWN
: I looked at the email mesage, and found out in the headers of the email:
: Content-Type: TEXT/PLAIN; charset=X-UNKNOWN
: obviously it was the charset's problem..
: How can solve this problem?
: Thanks.

c*y
发帖数: 137
3
The emails header has an entry says:
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN
I don't think X-UNKNOWN is a valid charset... hehe. anyway, what I did is
before call getContent(), I call getContentType(), if it's sth weird, then I
just use writeTo() to write the raw data into a file without decoding it...
hehe.

【在 g****y 的大作中提到】
: what is in that email?
: guess u must have ur program support X-UNKNOWN...
:
: program:
: exception

r*****s
发帖数: 985
4
Suppose you are using Java Mail API. For messages with attachment,
you cannot use msg.getContent() directly. Instead, you need to get its
Part object first. Then getContent() from it. The content could be
text string, or Multipart. If the latter, you will have to do it
recursively ...

【在 c*y 的大作中提到】
: I am writing an email client. There are several lines like this in the program:
: message.getContent()
: Then for one email I got an exception which will abort the operation, the exception
: is:
: java.io.UnsupportedEncodingException: X-UNKNOWN
: I looked at the email mesage, and found out in the headers of the email:
: Content-Type: TEXT/PLAIN; charset=X-UNKNOWN
: obviously it was the charset's problem..
: How can solve this problem?
: Thanks.

c*y
发帖数: 137
5
As far as I know, for a msg with attachment, its bodypart is an multipart,
so your first use getContent() to get the multipart, then process the
parts in the multipart.
This problem was not due to multipart, but because some application put
X-UNKNOWN in "content-type" field, which java parse can't deal with..

【在 r*****s 的大作中提到】
: Suppose you are using Java Mail API. For messages with attachment,
: you cannot use msg.getContent() directly. Instead, you need to get its
: Part object first. Then getContent() from it. The content could be
: text string, or Multipart. If the latter, you will have to do it
: recursively ...

e***g
发帖数: 158
6

nobody can... the client has to guess, or let user to select.

【在 c*y 的大作中提到】
: As far as I know, for a msg with attachment, its bodypart is an multipart,
: so your first use getContent() to get the multipart, then process the
: parts in the multipart.
: This problem was not due to multipart, but because some application put
: X-UNKNOWN in "content-type" field, which java parse can't deal with..

1 (共1页)
进入Java版参与讨论
相关主题
Documentum DFC怎麼得到字符串中的raw bytes?
急问:java如何处理中文字符问个xml的问题
[转载] 请问如何改变Oracle 9i AS中JVM的default encoding一个想不明白的编码问题
Question about displaying Chinese请教个html显示utf8 string的问题 (转载)
显示email中文的问题我脑袋短路,大家来帮一下:
SpringMVC可否直接处理doGet?Spring JDBC无法正确插入blob到MySQL
请教汉字的utf-8 mapping (转载)getBytes() 卡住了 求助
遇到一个程序运行错误火车旅行家在中文WINDOWS下无法运行的大问题已被解决
相关话题的讨论汇总
话题: content话题: unknown话题: type话题: charset话题: multipart