views:

25

answers:

1

Hi, 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.Settings);
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);
A: 

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.

Peter Bailey
So what you are saying is that Facebook has a bug because they parse the text wrong?
doggelito
No, that's not what I'm saying at all. I'm saying your FacebookApp class isn't decoding the JSON for you - so that's a step you'll have to take on your own.
Peter Bailey
Oh, ok. Then it has to be a bug in Facebook.net sdk then!? I'm just sending in a plain utf-8 string into the sdk so I can't see how I can do anything else with it.
doggelito
I guess so - I've only used the PHP SDK so I can't really say.
Peter Bailey
Ok, thanks Peter for your answers. :) I will contact the developers of the facebook.net and check with them.
doggelito