我有一个Q 编码的字符串变量:
String s = "=?ISO-8859-1?Q?Merve_G=FCl?=";
我想用真正的角色在屏幕上写它:“Merve Gül”。
我怎样才能做到这一点?
@缺口
String string = "=?ISO-8859-1?Q?Merve_G=FCl?=";
QCodec q = new QCodec();
try
{
q.decode(string);
System.out.println(q.decode(kimdenIsim));
} catch (DecoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我收到此错误:
05-08 11:22:39.287: W/System.err(1142): org.apache.commons.codec.DecoderException: RFC 1522 violation: malformed encoded content
05-08 11:22:40.448: W/System.err(1142): at org.apache.commons.codec.net.RFC1522Codec.decodeText(RFC1522Codec.java:102)
05-08 11:22:40.448: W/System.err(1142): at org.apache.commons.codec.net.QCodec.decode(QCodec.java:230)
05-08 11:22:40.457: W/System.err(1142): at com.mobil.eposta.GoruntuleActivity.EksizPosta(GoruntuleActivity.java:138)
05-08 11:22:40.457: W/System.err(1142): at com.mobil.eposta.GoruntuleActivity.onCreate(GoruntuleActivity.java:52)
05-08 11:22:40.477: W/System.err(1142): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-08 11:22:40.477: W/System.err(1142): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-08 11:22:40.477: W/System.err(1142): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-08 11:22:40.497: W/System.err(1142): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-08 11:22:40.497: W/System.err(1142): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-08 11:22:40.507: W/System.err(1142): at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 11:22:40.517: W/System.err(1142): at android.os.Looper.loop(Looper.java:123)
05-08 11:22:40.517: W/System.err(1142): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-08 11:22:40.517: W/System.err(1142): at java.lang.reflect.Method.invokeNative(Native Method)
05-08 11:22:40.517: W/System.err(1142): at java.lang.reflect.Method.invoke(Method.java:521)
05-08 11:22:40.517: W/System.err(1142): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-08 11:22:40.537: W/System.err(1142): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-08 11:22:40.537: W/System.err(1142): at dalvik.system.NativeStart.main(Native Method)
第 4 个错误行显示:q.decode(string);