I am trying to send a public key over SMS.
So far I convert the byte[] to a String using:
String message = new String(ByteArray, "iso-8859-1");
The public key looks like this(when sent):
0I0
*†H†÷ 8 05 .:y&¯GìL5VØÞ<£  ßÄ´Q•4YŸß ÈW8‰³S›‰_ó4aÀ”[Ù u
but the recipient receives the message like this:
0I0
*?H?? 8 05 .:y&?GìL5VØ?<£ A ?ßÄ?Q?4Y?ß?EW8??S??_o4aA?[U u
Some of characters are being corrupted and replaced with “?” the phone does not recognise them.
Question:
Is there a way of converting “iso-8859-1” to just letters and numbers?
if not does anyone have any other idea?
(maybe another type of encoding?)
Please comment if you would like more details, Thank you.
You can’t convert pure binary data into a String like this, because all the bytes don’t represent a valid character. Use base-64 to convert your byte array to a readable ascii string. Apache commons codec has a free implementation.