Java Convert 7bit Charset Octets to Readable String (From PDU SMS) -


i'm receiving sms gsm modem in pdu format; tp-user-data "c8329bfd06dddf72363904"
, is: "�2����r69", while sent sms "hello world!".

here java code:

    private string frompdutext(string pdusmstext) {     string endoding = pdusmstext.substring(0, 2);     pdusmstext = pdusmstext.substring(18);     byte bs[] = new byte[pdusmstext.length() / 2];     for(int = 0; < pdusmstext.length(); += 2) {         bs[i / 2] = (byte) integer.parseint(pdusmstext.substring(i, + 2), 16);     }     try {         string out = new string(bs, "ascii");     } catch(unsupportedencodingexception e) {         e.printstacktrace();         return "";     } {         return out;     } } 

the input packed in 7-bits per character, means every 8 bytes encode 9 characters. constructing parser format can fun exercise or frustrating experience, depending on how take it. better off using library, , quick google search reveals several code examples.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -