如何对法语/西班牙语字符进行编码以使用 clickatell 的 http api?
我认为你们中的一些人有与 Clickatell 合作的经验。我的问题是:当我使用法语或西班牙语字符(URL 编码)通过他们的 http api 发送消息时,它们不会在手机上显示(字符)。
我正在使用这个-指南-: http://support.clickatell.com /faq.php?mode=view_entry&kbid=121&kbcat=26
我已经用几部手机进行了测试,它们都显示相同的内容:“a va!mon l ve mi ni a? ” 应该是“ça va!mon élève mi niña?” (或类似的东西)
不幸的是,他们的支持不太具体(对我来说),我现在有点困惑,这就是我得到的:
请参阅:http://www.dreamfabric.com/sms/default_alphabet.html
之后,请按照上述标准对您的 text= 参数进行 URL 编码,以获得您的法语字符在手机上正确显示。
I think some of you have experience working with Clickatell. My problem is: when I send a message through their http api using french or spanish characters (URL encode), they are not displayed (the characters) on the phone.
I'm using this -guide-:
http:// support.clickatell.com /faq.php?mode=view_entry&kbid=121&kbcat=26
I already tested it with several phones and they all show the same: " a va! mon l ve mi ni a?"
It should be "ça va! mon élève mi niña?" (or something pretty similar)
Unfortunately their support is not quite specific (for me), and I'm a little confused now, this is what I got:
Please see: http://www.dreamfabric.com/sms/default_alphabet.html
Thereafter, please URL Encode your text= parameter according to the above standards to have your French characters display correctly on your handset.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
基本上,使用 SMS,您有两种发送文本的选项:或者使用 中指定的“默认字母表” GSM 03.38 或使用 Unicode。
默认字母表是大多数西方国家/地区发送短信的常用方式,因为它为该地区的语言提供了可接受的子集。它是 7 位编码,因此您可以在 140 个可用字节中容纳最多 160 个字符。 “最多”,因为这种编码使用了多个表。您可以通过在字符前添加转义字符 (0x1B) 来访问扩展表中的字符。因此,如果您主要使用第一个表,则 7 位编码可以节省空间。
另一种选择是使用 Unicode(特别是 UCS-2)。显然,这为您提供了更广泛的字符集,但以空间为代价:每个字符使用两个字节,这种编码使您的字符数限制为 70 个。
我不能代表 Clickatell,因为我从未使用过它们,但一些提供商为您提供了一个抽象 API,让您可以使用流行的编码,例如 ISO-8859-1(“latin-1”)。在某些时候,这仍然被重新编码为 7 位默认字母表。甚至可以应用一些映射规则,例如使用“è”而不是“é”,因为前者看起来几乎相同并且在默认字母表中。当然,如果您想完全控制内容,那么您需要使用 API,让您传输以 GSM 默认字母表编码的文本。
Basically with SMS you have two options for sending text: either use the "default alphabet" that is specified in GSM 03.38 or use Unicode.
The default alphabet is the usual way to send SMS in most western countries, as it offers an acceptable subset for the languages in this region. It is a 7 bit encoding, therefore you can fit up to 160 characters into the 140 bytes available. "Up to", because this encoding uses several tables. You can access characters in extension table(s) by prefixing the character with escape(s) (0x1B). So the 7 bit encoding saves place if you are mostly using the first table.
The other option is to use Unicode (specifically UCS-2). Obviously this gives you a much broader character set but at the cost of space: using two bytes for each character this encoding leaves you with a 70 character limit.
I can't speak for Clickatell, as I never used them, but some providers offer you an abstract API that let's you use popular encodings such as ISO-8859-1 ("latin-1"). At some point this is still recoded to the 7 bit default alphabet. Even some mapping rules may be applied, e.g. use 'è' instead of 'é' because the former looks almost the same and is in the default alphabet. Of course, if you want to have full control over the content then you need to use an API that lets you transmit text encoded in the GSM default alphabet.
这是一些解决方法。所有带有“^”的字符都将被替换为常规字母:
收到的短信将如下所示:
Here's some workaround. All characters with '^' will be replaced by the regular letter:
The recieved SMS will look like this:
我建议使用 Latin 1 编码,可能不是 100%,但它是最接近的你会得到的。 http://www.w3schools.com/PHP/func_string_htmlentities.asp
I would suggest using Latin 1 encoding, might not be 100 percent but it's the closest you're going to get. http://www.w3schools.com/PHP/func_string_htmlentities.asp
实际上,我只使用 $message = utf8_encode($cvPath); //$cvpath表示url。它可以成功。感谢您的想法分享。 ^^
Actually, I use only the $message = utf8_encode($cvPath); //$cvpath that the url. it can work success. Thank for your idea sharing. ^^