将 —
发送到 foursquare 时,它显示为 ?在他们的网站上,而不是——,长破折号。它在 Android 应用程序中看起来很好(我使用\u2014 显示它),但在 foursquare 网站上却不行。我知道网站可以处理符号,因为我可以在网站上进行编辑时添加它。事实上,该网站似乎使用\u2014 渲染它。所以从它被发送到服务器然后在页面上呈现回来的时候就发生了一些事情。非常感谢任何帮助。
我使用以下方式添加破折号:
mDetailPlaceholder.setText("\u2014 at " + mVenueName);
然后我像这样将字符串传递给 foursquare API:
String shout = mDetailText.getText().toString() + " " + mDetailPlaceholder.getText().toString();
可能是在使用 toString() 时丢失了 unicode,因此发送了原始破折号。
最佳答案
必须在发送到 foursquare 服务器之前将编码样式设置为 utf-8:
req.setEntity(new UrlEncodedFormEntity(params, "utf-8"));
... 其中 req 是一个 HttpPost 对象,params 是一个 List 对象。
关于java - Android、Foursquare 和 —特点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25539064/