views:

302

answers:

1

I am parsing the public timeline xml from twitter and want to display images next to the statuses.

The problem is some image urls contain strange characters:

e.g.

http://s3.amazonaws.com/twitter_production/profile_images/68803670/Gryn_i_h%E4ngmattan_normal.jpg

Some of the characters can be replaced with urlencode, but I have no idea what to do with asian text or other strange urls.

All I want is something that will return me the default twitter profile png if no valid image url is supplied.

Any hints ?

A: 

I believe you should use UTF-8 Encoding instead. The correct URL would then be: http://s3.amazonaws.com/twitter_production/profile_images/68803670/Gryn_i_h%C3%A4ngmattan_normal.jpg

Doesn't flash do that automatically when you read the string from the utf-8 encoded public timeline xml? If you just output the link http://s3.amazonaws.com/twitter_production/profile_images/68803670/Gryn_i_hängmattan_normal.jpg the browser should take care of the encoding, no?

Edit: looks like the SO code has problems with non-ascii characters in a url as well :)

Ben Schwehn
but ... but ... non-ascii chars aren't even allowed in an url, that's what urlencoding is for in the first place. and yes, the problem here is that the singlebyte (ISO) string is encoded, not the multibyte (utf) one.
Schnalle
but in the actual url there is no unicode, it's encoded into e.g. %C3%A4 for ther umlaut ä. The browser will do that for you.
Ben Schwehn
George Profenza
what I mean is, if you type http://s3.amazonaws.com/twitter_production/profile_images/68803670/Gryn_i_hängmattan_normal.jpg into your browser's location box it will issue an GET /twitter_production/profile_images/68803670/Gryn_i_h%C3%A4ngmattan_normal.jpg HTTP/1.1I don't see why you shouldn't just have utf-8 encoded URL in an UTF-8 encoded html page and let the browser do what's neccessary, but there might be good reasons?Firefox even shows the unicode glyph and not the encoding when you type a UTF-8 encoding into the address bar.
Ben Schwehn
Thanks Ben! Didn't have time to check back and say thanks until now.
George Profenza