This discussion is archived
4 Replies Latest reply: Jul 10, 2012 2:05 PM by DrClap RSS

Issue while sending SMS from JavaMail in languages like Russian & Japanese

user5450633 Newbie
Currently Being Moderated
Hi,

We have a requirement to send multi lingual SMS to users mobile number.
We are using JavaMail API for this. The only changes we have done to send SMS (instead of EMAIL) using a standard JavaMail code are –

1)     Use the suffix @sms after the mobile number. For eg: 919923456789@sms.<domain>.com.
2)     Use “text/plain” instead of “text/html” while setting the content type.

The SMS is sent fine for English and French but we get junk characters for languages like Japanese and Russian even on phones which support these languages.

Could anyone please advice on the below points –

1)     Is this a limitation with respect to JavaMail? If yes, is there any other api that can be used?
2)     Does some setting needs to be done in the SMS gateway to enable sending SMS in Japanese and Russian?
3)     Does some setting needs to be done in the mobile phone to receive SMS in Japanese and Russian?


Any help on this issue will be appreciated.

Thanks and Regards,
Jacob
  • 1. Re: Issue while sending SMS from JavaMail in languages like Russian & Japanese
    bshannon Pro
    Currently Being Moderated
    I can't help you at all with the SMS part of this but you could try testing it by sending it to a regular email address.

    Also, what charset are you using when you set the text content of the message?
    Try both "utf-8" and an appropriate Japanese or Russian charset.
  • 2. Re: Issue while sending SMS from JavaMail in languages like Russian & Japanese
    DrClap Expert
    Currently Being Moderated
    My 30 seconds of googling suggests that the UCS-2 character set should be used for languages which don't use a Latin script. That would be UTF-16 in Java (or possibly UTF-16BE or UTF-16LE).
  • 3. Re: Issue while sending SMS from JavaMail in languages like Russian & Japanese
    user5450633 Newbie
    Currently Being Moderated
    Thanks for your replies...... Please find below the code snippet where I am setting the encoding.....Could you please confirm if this is the correct way?

    ***********************************************************************************
    String subject = "\u0421\u0442\u0430\u0442\u0443\u0441 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u0433\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F";


    String body = "\u0421\u0442\u0430\u0442\u0443\u0441 \u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u0433\u043E \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F";

    *//Both 'body' and 'subject' are set as the russian translation of 'Status last updated'.*

    MimeMessage msg = new MimeMessage(mailSession);
    msg.setHeader("Content-Type", "text/plain; charset=UTF-16");

    msg.setSubject(subject, "UTF-16");
    msg.setText(body, "UTF-16");

    *************************************************************************************

    I tried this but still not getting correct text. If I try with "UTF-16BE"/"UTF-16LE", then I do not get an SMS at all. I have tried with UTF-8 as well.

    Does it matter if I change the phone language before/after I receive the message in a language different from the currently set phone language?

    I am based out of India and am trying to send these messages to some of my colleagues who are all using Indian service providers. I have tried this on phones which have Russian as a language option.

    Regards,
    Jacob
  • 4. Re: Issue while sending SMS from JavaMail in languages like Russian & Japanese
    DrClap Expert
    Currently Being Moderated
    No, I can't confirm that. As you know I didn't spend a lot of time on the research, and all I found was a page which seemed to mention UTF-16 as an after-thought. I'm sure that the SMS specification must have something in it which explains how to support non-Latin character sets, since (I assume) your Russian associates can send and receive Cyrillic texts? So I suggest you go and find the SMS spec.

    I also have no experience with sending or receiving texts on phones configured in non-Latin scripts, but I suggest that you could do the experiment which answers your other questions quite easily.

    It's also possible that the service which converts your e-mails to texts has some encoding requirement which you haven't asked them about.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points