Twilio 的 SMS 服务中的 SmartEncoding 能否通过 C# API 发送 GSM-7 字符,如 éÉÑñ?

Can SmartEncoding in Twilio's SMS service send GSM-7 characters like éÉÑñ via C# API?

我正在使用 Twilio's SMS service, and I want to be able to send ordinary non-English Roman-alphabet characters (for European personal names) along with ASCII characters. The characters I need are a subset of Unicode's "Latin-1 Supplement Block". And, they're all in the GSM-7 character set。但它们作为替代字符出现在手机上。例如,当我发送 J'aime l'été... éÉÑñ 时,phone 显示 J'aime l'?t?... ????.

我正在测试美国 iPhone 和 iOS 13 运行 的 Sprint。 Verizon iPhone 显示同样的问题。

这是重现问题的 C# 代码。将 smartEncoded 的值从 true 更改为 false 或反之亦然

        const string sid = "REDACTED";
        const string token = "REDACTED";
        const string from = "REDACTED";

        const string to = "REDACTED";
        const string message = "J'aime l'été... éÉÑñ";

        TwilioClient.Init(sid, token);
        var msg = MessageResource.Create(
            body: message,
            from: new Twilio.Types.PhoneNumber(from),
            to: new Twilio.Types.PhoneNumber(to),
            smartEncoded: true
            );

Twilio claims they use GSM-7 在他们可以使用该字符集时发送消息,而在他们不能使用时回退到使用 UCS-2。

如果我发送一条消息强制 Twilio 使用 UCS-2 编码,一切正常。例如,附加 ® 就可以了。当然,每条以 UCS-2 发送的 SMS 消息的最大长度更短。

        const string message = "J'aime l'été... éÉÑñ ®";

我一定是漏掉了什么; Twilio 以其消息大小优化功能而自豪。我怎样才能解决这个问题?

tl;dr:某些短消息服务中心的已知问题可以通过将消息强制转换为 Unicode 来解决(无需额外费用) 通过强制至少两个段(额外费用,因为您按分段收费,并且您将拥有更多分段)。

我向 Twilio 支持人员询问了我在 Verizon 上遇到的 same/a 类似问题,当时我的 GSM 编码消息包含“扩展 GSM 字符”,并收到以下回复:

There is a known encoding issue with messages that are routed to certain Verizon short message service centers. Verizon has many SMSCs (short message service centers) and they are dynamically assigned (i.e. one particular Verizon user may get messages through many different SMSCs at varying times).

Is this issue you are seeing occurring specifically for single-segment messages? If so, it matches an encoding issue we have seen on certain Verizon SMSC's that has been present since 2018. For single-segment SMS, certain Verizon SMSCs may convert "ñ" or other extended GSM characters ((à ò è ì ù ¿ Ñ ñ ¡) to "?" upon delivery.

Unfortunately, we do not have additional device-related specifics, aside from the fact that this impacts some Verizon SMSCs.

To avoid this issue, we recommend the following:

Option 1: Force the message to be sent as Unicode by including a non-GSM character. To send the message in unicode without adding extra cost by sending >160 characters you can include the Punctuation Space with the message. It looks just like a regular space, but because it's outside of the regular GSM-7 range it will cause the entire message to be converted to Unicode and the accents will come through correctly. Would you be able to test this as a workaround? Please note that USC2 messages will be limited to 70 chars per segment.

Option 2: Ensure the message is more than 1 segment long in GSM encoding.

根据 https://www.twilio.com/docs/sms/services/smart-encoding-char-list,“标点符号 Space”是 U+2008

请注意,Twilio 按分段收费,因此如果您选择选项 2,您将支付更多费用,因为您将发送更多分段。

Twilio 提供 this tool 让您了解您的消息将使用什么编码 它需要多少段。