[英]URLDecoder: Illegal hex characters in escape (%) pattern - For input string: “^*”
i want to send an email this text 我想通过电子邮件发送此文本
Destination : 6W - ATLANTA WEST!@#$%^*!gemini!@#$%^*!jfds!@#$%^*!,Trailer Number : 000564,,Drop empty trailer at Plant Numbe :546,Pick up trailer at Plant Number :45, Bill Date : 25-Jan-2013,Bill Time - Eastern Time : 1,Trip Number :456,MBOL :546,Carrier :Covenant!@#$%^*!test@shaw.com!@#$%^*!transport@shaw.com!@#$%^*!test@transport.com!@#$%^*!antoalphi@gmail.com,Destination : 6W - ATLANTA WEST!@#$%^*!gemini!@#$%^*!jfds!@#$%^*!,Customer Name : 567,Cusomer Delivery Address : 657567657,General Comments :657,Warehouse Comments : 65,Carrier Comments : ,Appointment Date :25-Jan-2013,Appointment Time : 1am,Rail Only :Standard,Total Weight : 45645
and i used this mailContent = URLDecoder.decode(Body, "UTF-8");
我用了这个
mailContent = URLDecoder.decode(Body, "UTF-8");
decode, 解码,
but it is giving me this exception URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "^*"
但它给了我这个异常
URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "^*"
could any one of you help me,how to solve this. 你们中的任何一个可以帮助我,如何解决这个问题。 I get this while sending mail.
发送邮件时收到此消息。
Best Regards 最好的祝福
You are trying to URL decode something that wasn't URL encoded in the first place. 您正在尝试对最初不是URL编码的内容进行URL解码。 What's wrong with the body as it is?
身体到底有什么问题? In other words, what happens if you just use:
换句话说,如果您仅使用以下内容会发生什么:
mailContent = Body
(In URL encoding, the % character is used with two hexadecimal digits to encode characters that might cause problems, for example /
would be encoded as %2F
, as its ASCII code is 47 (decimal) or 2F (hex). In your body, %
is followed by two characters that are not hexadecimal digits - that's how I can tell it hasn't been URL encoded, and why the decoder is erroring.) (在URL编码中,%字符与两个十六进制数字一起使用,以编码可能引起问题的字符,例如
/
会被编码为%2F
,因为其ASCII码为47(十进制)或2F(十六进制)。在您的体内, %
后跟两个不是十六进制数字的字符-这就是我可以知道它尚未经过URL编码的原因,以及解码器出错的原因。)
Simply stop calling URLDecoder.decode() and you will stop getting the error! 只需停止调用URLDecoder.decode(),您将停止获取错误! The string value you are passing to it is not URL encoded.
您传递给它的字符串值未经URL编码。
There are various forms of MIME encoding that you might want to consider, if you are sending an email with content that would not normally be allowed in an email message without encoding. 如果要发送的电子邮件中包含未经编码通常不允许在电子邮件中包含的内容,则可能需要考虑多种形式的MIME编码。 There references might be handy:
那里的参考可能很方便:
For example, you might try: 例如,您可以尝试:
String sendable = MimeUtility.encodeText(body,"UTF-8","BASE64")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.