Monday, May 30, 2011

Posting on Twitter

I found out the hard way that when working on a multi-language application or website that posts on Twitter you need to be careful with accentuation and "strange" characters (e.g.: ü, è, à, ä, etc).

A simple way to bypass this problem is using the global function encodeURI().
Check out the docs:

I'll give a simple example on how to use it:

var urlrequest : URLRequest = new URLRequest();

urlrequest.url = "http://twitter.com/intent/tweet?text=" + encodeURI( completeURL );

navigateToURL( urlrequest, "_blank" );

Hope it helps someone out there to spare some development time ;)