简体   繁体   English

短信编码

[英]Encoding for SMS messages

I'm currently building an application which uses Nexmo to send SMS messages to users.我目前正在构建一个使用Nexmo向用户发送 SMS 消息的应用程序。 But I'm experiencing some problems with the encoding of messages.但是我在消息编码方面遇到了一些问题。 Probably worth metioning;可能值得一提; I'm using the prawnsalad/Nexmo-PHP-lib library to connect with their API.我正在使用prawnsalad/Nexmo-PHP-lib 库来连接他们的 API。

A simple text messages of 160 characters is divided into 3 separate messages.一条 160 个字符的简单文本消息被分成 3 条单独的消息。 According to the Nexmo support, this is caused by the encoding of the message.根据 Nexmo 支持,这是由消息的编码引起的。 So to provide me with some more information I recevied the follow information about the encoding:因此,为了向我提供更多信息,我收到了有关编码的以下信息:

The maximum number of characters per message depends on the encoding: - 160 characters for 7-bit encoding (eg Latin-1/9 and GSM8) - 140 characters for 8-bit encoding (Binary) - 70 characters for 16-bit encoding (Unicode)每条消息的最大字符数取决于编码: - 7 位编码为 160 个字符(例如 Latin-1/9 和 GSM8) - 8 位编码为 140 个字符(二进制) - 16 位编码为 70 个字符(统一码)

The maximum number of characters per concatenated message depends on the encoding: - 153 characters for 7-bit encoding (eg Latin-1/9 and GSM8) - 134 characters for 8-bit encoding (Binary) - 67 characters for 16-bit encoding (Unicode)每个串联消息的最大字符数取决于编码: - 7 位编码(例如 Latin-1/9 和 GSM8)为 153 个字符 - 8 位编码(二进制)为 134 个字符 - 16 位编码为 67 个字符(统一码)

When I use the 7BIT encoding ( mb_convert_encoding('message', '7bit') ) the entire message goes out as a single text message... BUT characters like "é", "è", "à", "ù" are removed from the message.当我使用 7BIT 编码 ( mb_convert_encoding('message', '7bit') ) 时,整个消息作为单个文本消息发出...但是像“é”、“è”、“à”、“ù”这样的字符是从消息中删除。 There must be a way to include this charachters and still send out the message as 1 message and not 3.. right?必须有一种方法来包含这些字符,并且仍然将消息作为 1 条消息而不是 3.. 发送出去,对吧? But how?但是怎么办?

I really hope that someone here can help with this issue, even the support of Nexmo took a step back from this encoding issue:p我真的希望这里有人可以帮助解决这个问题,即使是 Nexmo 的支持也从这个编码问题中退了一步:p

Unfortunately these characters are not included in the GSM8 encoding, which is explained in great detail here: http://www.clockworksms.com/blog/the-gsm-character-set/不幸的是,这些字符不包含在 GSM8 编码中,这里有非常详细的解释: http://www.clockworksms.com/blog/the-gsm-character-set/

If you're required to use those characters there is no way around 8-bit encoding and thus fewer characters.如果您需要使用这些字符,则无法绕过 8 位编码,因此字符会更少。

The same thing happens if your SMS on your mobile shows current character usage, then the character count changes drastically whenever you are using characters not included in the GSM8 encoding.如果您手机上的 SMS 显示当前字符使用情况,则会发生同样的事情,然后每当您使用 GSM8 编码中未包含的字符时,字符数就会发生巨大变化。

Nexmo/Vonage supports two main types of encoding for the SMS API: text and unicode. Nexmo/Vonage 支持 SMS API 的两种主要编码类型:文本和 unicode。

Unicode is limited to 70 characters, Text is 160. Nexmo PHP lib is by default set to Unicode, you have to set it to text Unicode 限制为 70 个字符,Text 为 160。Nexmo PHP lib 默认设置为 Unicode,您必须将其设置为文本

new SMS($sms_number, $sms_from, $sms_content, 'text') 

You can use this characters in Text without problem: "é", "è", "à", "ù".您可以毫无问题地在文本中使用这些字符:“é”、“è”、“à”、“ù”。

More information in Nexmo SMS encoding documentation Nexmo SMS 编码文档中的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM