问题描述
Twitter 的流媒体 API 的官方编码是什么?我最好的猜测是基于我所看到的 UTF-8,但我想避免做出假设.
What is the official encoding for Twitter's streaming API? My best guess is UTF-8 based on what I've seen, but I would like to avoid making assumptions.
我在 Twitter 网站上看到的唯一一个部分,其中他们甚至暗示了他们用作官方编码的内容:
The only part of the Twitter site I've seen where they even hint at what they use as their official encoding is here:
Twitter 不想因为我们使用 UTF-8 或有问题的 API 客户端使用更长的表示而惩罚用户
https://dev.twitter.com/docs/counting-characters
有没有更官方"的?回答?我正在为流 API 编写一个状态机标记器,它做出了某些假设.我最不想遇到的就是像 UTF-16 这样的东西.
Does anyone have a more "official" answer? I'm writing a state-machine tokenizer for the streaming API which makes certain assumptions. The last thing I want is to encounter something like UTF-16.
谢谢!:D
推荐答案
一个指标是 JSON 格式,Twitter 几乎用于所有内容,规定(或至少默认为)UTF-8.他们应该还设置一个适当的 HTTP 标头来表示编码(但我还没有确认).如果您改用 XML,则 XML 开始标记明确表示编码,即 UTF-8.
One indicator is that the JSON format, which Twitter uses for virtually everything, dictates (or at least defaults to) UTF-8. They should also set an appropriate HTTP header denoting the encoding (but I haven't confirmed this). If you're using XML instead, the XML opening tag explicitly denotes the encoding, which is UTF-8.
这篇关于Twitter Streaming API 使用的官方编码?是UTF-8吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!