I'm trying to decode a string from my vcard
ADR;WORK;;ENCODING=QUOTED-PRINTABLE:;Building 723 Room 317;;Auckland;;Private Bag 92019 Auckland;New Zealand
into standard text to display on my Android view. I have already parsed the address field with a vCard parser, using the example in http://android-vcard.googlecode.com/hg/examples/ReadExample.java .
I have followed the suggestion here for decoding: to use the codec library. However, it is still displaying the string as ;Building 723 Room 317;;Auckland;;Private Bag 92019 Auckland;New Zealand
instead of decoding it.
My decoding code:
byte[] byteAddress = address.getBytes();
String decodedAddress = "";
try {
decodedAddress = new String(QuotedPrintableCodec.decodeQuotedPrintable(byteAddress));
} catch (DecoderException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView textView4 = (TextView) findViewById(R.id.address);
textView4.setText(decodedAddress);
That is because a quoted-printable string of ;Building 723 Room 317;;Auckland;;Private Bag 92019 Auckland;New Zealand
is exactly the same as the unencoded string. The semicolons ;
have nothing to do with quoted-printable encoding, instead, adr
is a structured element that uses semicolons to denote its parts, in this order:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.