Japanese text not visible in mobile

2020-02-15 13:27发布

问题:

I am sending text message having Japanese characters.

Here is my message

In japanese

このOTPを使用してQuikドライブにログインします。 このOTPを誰とも共有しないでください

In English

use this OTP to login to Quik Drive. Please don't share this OTP to anyone

Here what I am getting

Here what I am getting on my mobile phone

Here is my nodejs code

class ClickatellService {
  constructor() {
    this.sendSms('+mobileNumber', 'このOTPを使用してQuikドライブにログインします。 このOTPを誰とも共有しないでください')
  }

  sendSms(to, message) {
    return new Promise((resolve, reject) => {
      request.get(
        `https://api.clickatell.com/http/sendmsg?user=XXX&password=XXX&api_id=XXX&to=${to}&text=${encodeURI(
          message
        )}`,
        (error, response, body) => {
          if (error) {
            return resolve(error)
          } else {
            return resolve(response)
          }
        }
      )
    })
  }
}

What I can do to be getting the message in simple japanese language.

Any help would be appreciated!!!

回答1:

You probably need to set the charset to UTF-8 before sending. I don't know what the actual charset your'e using in your code but make sure its UTF-8.

If you already using UTF-8, make sure the actual Font you using is able to handle the Japanese letters.

For more explanation on how to handle Japanese letters, maybe you should check this:

https://www.kanjidatabase.com/japanese_developer_tips.php



回答2:

You need to use Unicode to send non GSM characters via SMS and then also set the unicode parameter.

Here is a PHP example:

$converted = iconv(
    "UTF-8", 
    "UCS-2BE", 
    "このOTPを使用してQuikドライブにログインします。 このOTPを誰とも共有しないでください"
);

$sms_data = urlencode(bin2hex($converted));

http://api.clickatell.com/....text=$sms_data&unicode=1

NOTE: Unicode messages are generally shorter than non-unicode messages, so be careful as you may pay for more than one message, detailed info over here:

https://archive.clickatell.com/developers/api-docs/concatenation-advanced-message-send/

Snippet:

70 (16-bit) characters allowed in a single SMS message part 67 (16-bit) characters used per message part when sending concatenated messages