Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Parameterize using Transliterate Doesn't work with Arabic/Unicode Strings

I have a string containing Arabic charachters "محمود"

When I try to parameterize this string, it returns empty string ""

x = "محمود"
x.parameterize    => ""

I have checked parameterize code and found it calls I18n.transliterate which returns question marks "?????"

I tried to customize transliteration referring to previous question How do you customize transliterations in a Rails 3 app?

But still returning blank string.

Any help?

like image 340
Mahmoud Khaled Avatar asked Oct 19 '11 16:10

Mahmoud Khaled


1 Answers

The parameterize method is supposed to render the string URL safe, and there's a strict limit on what kind of characters can appear in the URL. Generally anything not strictly a-z or 0-9 or - is stripped.

You could always try and fix it so that multi-byte UTF-8 characters are admitted by default. The current implementation is really quite lacking. Instead of allowing only a small set of specific characters, a more robust version would strip out the troublesome ones.

like image 82
tadman Avatar answered Oct 03 '22 06:10

tadman