开发者

Encoding problem using facebook.net sdk

I'm using the facebook.net sdk to send articles to a facebook fanpage. That works fine except for some swedish encoding problems. The article heading in facebook looks like this: "H\u00e5ret avsl\u00f6jar om du stressar" but should look like: "Håret avslöjar om du stressar".

What should I do to fix this?

The code:

FacebookApp app = new FacebookApp(post.Set开发者_如何学JAVAtings);
dynamic parameters = new ExpandoObject();
parameters.name = post.Name;
parameters.message = post.Mesesage;

dynamic result = app.Api(string.Format("/{0}/feed", post.PageID), parameters, HttpMethod.Post);


That's not an encoding issue in the traditional sense (i.e., bytes-to-characters), but rather a JSON parsing one.

The JSON standard forgoes traditional encoding conventions, and instead converts non-ASCII characters in to Unicode escape sequences that look like \uXXXX where XXXX is the four hex digits that represent the character's Unicode code point.

All JSON parsers should handle the transformation of these escape sequences into properly encoded characters for you.

In short - almost all the data you get from the Graph API is going to be JSON, so parse accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜