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 "?????"
我检查了参数化代码,发现它调用了I18n.transliterate,返回问号“?????”
I tried to customize transliteration referring to previous question How do you customize transliterations in a Rails 3 app?
我尝试自定义音译,参考上一个问题如何自定义Rails 3应用程序中的音译?
But still returning blank string.
但仍然返回空白字符串。
Any help?
1 个解决方案
#1
3
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.
参数化方法应该使字符串URL安全,并且对URL中可以出现的字符类型有严格的限制。通常,任何不严格的a-z或0-9或 - 都会被剥离。
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.
您可以随时尝试修复它,以便默认允许使用多字节UTF-8字符。目前的实施非常缺乏。不仅仅允许一小组特定字符,更强大的版本将剥离麻烦的版本。
#1
3
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.
参数化方法应该使字符串URL安全,并且对URL中可以出现的字符类型有严格的限制。通常,任何不严格的a-z或0-9或 - 都会被剥离。
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.
您可以随时尝试修复它,以便默认允许使用多字节UTF-8字符。目前的实施非常缺乏。不仅仅允许一小组特定字符,更强大的版本将剥离麻烦的版本。