Windows 自动选择最佳字符编码

Windows 8、Windows 8.1和Windows 10根据消息内容支持的最有效编码,选择在发送短信时使用的最佳字符编码。 SMS 采用 7 位字符集进行编码,除非它包含至少一个无效字符,在这种情况下,整个消息将采用 Unicode 编码。

使用文本模式接口发送短信的 JavaScript 代码示例

try
{
    if (smsDevice != null)
    {
      // defines a text message
      var smsMessage = new Windows.Devices.Sms.SmsTextMessage();
      smsMessage.to = id("phoneNumber").value;
      smsMessage.body = id("messageText").value + "\n\nSent via Windows 8 SMS API";
      var sendSmsMessageOperation = smsDevice.sendMessageAsync(smsMessage);
      console.log("Sending message...");
      sendSmsMessageOperation.then(function (reply)
      {
        console.log("Text message sent.");
      });
    }
    else
    {
      console.log("No SMS device found");
    }
} catch (err) {
    console.log("SMS exception: " + err);
}

(可选)可以替代最佳编码功能并指定要使用的字符集。

Windows 8、Windows 8.1和Windows 10支持与 GSM (3GPP) 和 CDMA (3GPP2) 网络兼容的移动宽带网络适配器的常见字符集。

下表列出了文本模式 API 支持的字符编码:

网络类型 字符集 单个短信段的字符限制 多部分短信段的字符限制
GSM GSM 7 位默认字母表和 GSM 7 位默认字母扩展表 160 142
CDMA 7 位 ASCII 160 个 (可能因网络) 而异
CDMA Unicode 70 个 (可能因网络) 而异

GSM 字符集定义为 3GPP TS 23.038:“字母表和语言特定信息”。

使用文本模式界面读取收到的短信