Sometimes when creating websites in Arabic or Farsi we are forced to accept slugs* that are non-Latin, These links usually look nice on the address bar but that is the only place they look good. Once we copy paste that URL and pass it on to others each character turns into a strange ASCII unit.
Now that can also be acceptable if we were not going to use the slug, but in cases where we use that slug as an identifier for the article, news, or whatever it is associated with, then we have a problem. The problem is that our database has saved the slug in it's non-Latin form while when storing the slug as a variable it dispaly incorrectly.
While we see the slug as: سلام, the computer saves it as A3%B2% ... obviously any query against this will bring no results.
In order to save the correct term, the below function can be called:
Hopefully this can help someone out there who has been searching for results for a while.
* Slug: A useful way of making a URL meaningful for both visitor and Search Engines (i.e. http://www.website.com/article/this-is-known-as-a-slug)
comments powered by Disqus