Android 设备上短信的默认字符集/编码是什么?
如果有必要保持简单的话,我主要关心北美的英语手机。
具体来说,当发送/接收短信和彩信时,字符是如何编码的?有区别吗?
我最初的研究表明 UTF-8
是默认设置,但我也看到了针对美国设备的 US-ASCII
的引用以及针对其他语言环境的其他字符集。
If necessary to keep it simple I am primarily concerned with English handsets in North America.
Specifically- when sending/recieving SMS and MMS messages, how are the characters encoded? Is there a difference?
My initial research suggested that UTF-8
was the default, but I have also seen references to US-ASCII
for US devices and other charsets for other locales.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更多信息可以在这里找到:
字符集| Android 开发者
More information can be found here:
Charset| Android Developers
如果您使用 GSM 03.38 无法直接编码的表情符号或文本,那么美国的简短答案是 GSM 03.38 和 UTF-16BE。
发送/接收短信时,编码绝对不是 UTF-8,因为 UTF-8 不支持PDU 或 SMPP 协议。搜索 SMPP 规范,了解支持的内容。在所有受支持的编码中,唯一兼容 Unicode 的选项是 UCS-2BE。我的观察是,大多数手机(包括所有 Android 和 iPhone)只是 假设这实际上是 UTF-16BE 因为它允许完整的 Unicode 字符集(包括 Emojis
The short answer for the US is GSM 03.38 and UTF-16BE if you use Emojis or text that GSM 03.38 cannot encode directly.
When sending/receiving SMS the encoding is definitely not UTF-8 since that isn't supported by the PDU or the SMPP protocol. Search for the SMPP spec for clarification on what is supported. Out of all supported encodings, the only Unicode compatible option is UCS-2BE. My observation is that most phones (includes all Android and iPhone) just assume this is actually UTF-16BE because it allows for the complete Unicode character set (including things like Emojis ????️).
SMS also have special mandatory encodings under the GSM03.38 specification which is based on septets. They allow up to 160 characters per PDU (as with many encodings not all characters are 1 code unit).
MMS is another animal entirely which isn't supported well outside of North America. But for MMS encoding the following are available (big endian or network byte order assumed when not specified):
MMS, however, isn't typically used unless you send a very long message (longer than 4 PDUs which is 560 bytes on Android) or if your message includes an image or something that cannot be encoded as a plain SMS.
Worth noting also is that MMS is much slower than SMS because it uses the SMTP protocol with special addressing (not based on DNS) and special multipart content types (see MM4 for details on this).