Twittering an URL that contains arabic characters via intent/tweet


#1

I need to create a tweet vie inten/tweet?url=[…]. In general this is not a problem. But in my special case the url contains parts written in arabic. I can’t influence the urls because they are delivered through the customer. The url to be postet looks like this:

I escape this and in the result the url looks like this:

http%3A%2F%2Fwww.dw.de%2F%D8%A3%D9%88%D8%A8%D8%A7%D9%85%D8%A7-%D9%8A%D9%84%D8%BA%D9%8A-%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%87-%D9%85%D8%B9-%D8%A8%D9%88%D8%AA%D9%8A%D9%86-%D8%A8%D8%B3%D8%A8%D8%A8-%D9%85%D9%86%D8%AD-%D8%B3%D9%86%D9%88%D8%AF%D9%86-%D8%AD%D9%82-%D8%A7%D9%84%D9%84%D8%AC%D9%88%D8%A1%2Fa-17003030%3Fmaca%3Dara-DWApp_ar_1-7825-rdf

But this does not work, since Twitter only recognizes www.dw.de as url.

How can this situation be handled?


#2

Since the UTF-8 characters aren’t valid for the URL, you’ll first need to get them into a valid escaped format – before you escape the URL, first escape the characters:

http://www.dw.de/%D8%A3%D9%88%D8%A8%D8%A7%D9%85%D8%A7-%D9%8A%D9%84%D8%BA%D9%8A-%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%87-%D9%85%D8%B9-%D8%A8%D9%88%D8%AA%D9%8A%D9%86-%D8%A8%D8%B3%D8%A8%D8%A8-%D9%85%D9%86%D8%AD-%D8%B3%D9%86%D9%88%D8%AF%D9%86-%D8%AD%D9%82-%D8%A7%D9%84%D9%84%D8%AC%D9%88%D8%A1/a-17003030?maca=ara-DWApp_ar_1-7825-rdf

Now that you’ve escaped those characters you can escape the whole URL:

http%3A%2F%2Fwww.dw.de%2F%25D8%25A3%25D9%2588%25D8%25A8%25D8%25A7%25D9%2585%25D8%25A7-%25D9%258A%25D9%2584%25D8%25BA%25D9%258A-%25D8%25A7%25D8%25AC%25D8%25AA%25D9%2585%25D8%25A7%25D8%25B9%25D9%2587-%25D9%2585%25D8%25B9-%25D8%25A8%25D9%2588%25D8%25AA%25D9%258A%25D9%2586-%25D8%25A8%25D8%25B3%25D8%25A8%25D8%25A8-%25D9%2585%25D9%2586%25D8%25AD-%25D8%25B3%25D9%2586%25D9%2588%25D8%25AF%25D9%2586-%25D8%25AD%25D9%2582-%25D8%25A7%25D9%2584%25D9%2584%25D8%25AC%25D9%2588%25D8%25A1%2Fa-17003030%3Fmaca%3Dara-DWApp_ar_1-7825-rdf

And then attach it to a Tweet Intent URL:

https://twitter.com/intent/tweet?url=http%3A%2F%2Fwww.dw.de%2F%D8%A3%D9%88%D8%A8%D8%A7%D9%85%D8%A7-%D9%8A%D9%84%D8%BA%D9%8A-%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%87-%D9%85%D8%B9-%D8%A8%D9%88%D8%AA%D9%8A%D9%86-%D8%A8%D8%B3%D8%A8%D8%A8-%D9%85%D9%86%D8%AD-%D8%B3%D9%86%D9%88%D8%AF%D9%86-%D8%AD%D9%82-%D8%A7%D9%84%D9%84%D8%AC%D9%88%D8%A1%2Fa-17003030%3Fmaca%3Dara-DWApp_ar_1-7825-rdf

I think this should work.


#3