Rails Parameterization using Transliterate Doesn't work with Arabic / Unicode strings

I have a string containing the Arabic characters "محمود"

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

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

I checked the parameterized code and found that it calls I18n.transliterate, which returns the question marks "?????"

I tried setting up transliteration, citing the previous question. How do you set up transliteration in a Rails 3 application?

But still returns an empty string.

Any help?

+6
source share
1 answer

The parameterize method is supposed to provide a secure URL for the string and there is a strict limit on what characters can be displayed in the URL. Usually nothing is shy about az or 0-9 or - .

You can always try and fix this so that by default multibyte UTF-8 characters are entered. The current implementation is really not enough. Instead of allowing only a small set of specific characters, a more robust version will highlight unpleasant ones.

+3
source

Source: https://habr.com/ru/post/899628/


All Articles