tags:

views:

120

answers:

2

I am using tweetsharp to send tweets.

var response = _twitter.AuthenticateWith(item.TwitterToken, item.TwitterSecret)
    .Statuses().Update(HttpUtility.HtmlEncode(item.Tweet)).AsXml().Request().Response;

As you may have noticed, above I am HtmlEncoding the message this can cause the message to go over 140 chars? Is encoding the message this way necessary? Does tweetsharp or twitter recommend sending messages without encoding first?

+1  A: 

From here:

The Twitter API supports UTF-8 encoding. Please note that angle brackets ("<" and ">") are entity-encoded to prevent Cross-Site Scripting attacks for web-embedded consumers of JSON API output. The resulting encoded entities do count towards the 140 character limit. When requesting XML, the response is UTF-8 encoded. Symbols and characters outside of the standard ASCII range may be translated to HTML entities.

This says to me that you should indeed make sure that your output is encoded (not necessarily HTML encoded) to UTF-8. Have you tried to UTF-8 encode and then submit, then look at the output of "special" characters?

Kyle Rozendo
This says to me that the text must be UTF-8 character encoded, *and* that HTML entities must be escaped. ("entity-encoded")
dthorpe
+1  A: 

TweetSharp will handle all of the encoding for you. Just pass it the string you want to post.

Jason Diller
Aaron
We made some encoding fixes last night. Grab the latest code.
Jason Diller
I dub they captain awesome!
Aaron