Menu

sending Euro sign

arif
2015-05-25
2015-05-26
  • arif

    arif - 2015-05-25

    Hi,
    I'm trying to test GSM Extended character set alphabets in SMS. I'm trying to use DefaultAlphabetEncoding as it implements GSM 03.38 but the Euro sign is not displayed properly on handset. It is displayed as ? on the handset.

    SubmitSM sm = (SubmitSM) myConnection.newInstance(SMPPPacket.SUBMIT_SM);
    sm.setSource(new Address(5,0,Source));
    sm.setDestination(new Address(1, 1, To));
    AlphabetEncoding enc = new DefaultAlphabetEncoding();
    sm.setMessage("@ ! # $ % & * + _ - ) ^ { } | \ ~ ` \" ' ' [ ] ( €".getBytes());
    sm.setDataCoding(enc.getDataCoding());
    SubmitSMResp smr = (SubmitSMResp) myConnection.sendRequest(sm);

    The SMS I received on my phone is @ ! # $ % & * + _ - ) ^ { } | \ ~ ∆ \" ' ' [ ] ( ∆

    For the wireshark packet capture, I found the following packet data:

    Hex View:

    0000 00 20 21 20 23 20 02 20 25 20 26 20 2a 20 2b 20 . ! # . % & * +
    0010 11 20 2d 20 29 20 1b 14 20 1b 28 20 1b 29 20 1b . - ) .. .( .) .
    0020 40 20 1b 2f 20 20 1b 3d 20 3f 20 22 20 27 20 27 @ ./ .= ? " ' '
    0030 20 1b 3c 20 1b 3e 20 28 20 1b 65 .< .> ( .e

    0020212023200220252026202a202b2011202d2029201b14201b28201b29201b40201b2f20201b3d203f202220272027201b3c201b3e2028201b65

    Here I can see the Euro sign is properly encoded as 0x1b65 but on Handset it appears as 10.

    Another interesting part is when I removed the spaced between the special characters like following:

    sm.setMessage("@!#$%&*+_-)^{}|\~`\"';

    and the resulting encoded string is following:

    0000 40 21 23 24 25 26 2a 2b 5f 2d 29 5e 7b 7d 7c 5c @!#$%&*+_-)^{}|\ 0010 7e 60 22 27 5b 5d 28 88 ~`"'[](.

    Any help would be really appreciated.

    Regards,
    Arif

     
  • Oran Kelly

    Oran Kelly - 2015-05-26

    Hi,

    the main problem is the fact that you're calling String.getBytes. The bytes you are setting in the message are for the character encoding that your VM uses by default. You need to have DefaultAlphabetEncoding do the conversion from a String into bytes.

    sm.setEncoding(new DefaultAlphabetEncoding());
    sm.setMessageText("@ ! # $ % & * + _ - ) ^ { } | \ ~ ` \" ' ' [ ] ( €");
    

    I'm not sure how you got 0x1b65 for the euro character, I've not tried to decode the byte stream you posted.

     

Log in to post a comment.