关于ruby:比较特殊字符中具有不同字节的utf-8字符串

Comparing utf-8 string that have different byte in special characters

someobject.find(20)。client.full _ name.downcase.bytes.each {他} | | b b

  • 197 197 130 188 97 98 101 106 101 119 115

B"=>?a?ejewsk"otherclass.find(36)。client.downcase.bytes.each {他} | | b b

  • 197 197 129 98 97 187 101 106 101 119 115

B"=>?a?ejewsk"

你可以看到有不同的两个字节的特殊字符的字符串。有两个字符串编码,UTF-8编码,那么力_或什么,不会有帮助的。= =返回FALSE。我应该把这些知识,这样我可以得到从字符串比较真实?


它不适用于downcase,请参见http://www.ruby-doc.org/core-2.1.0/string.html method-i-downcase-21

Returns a copy of str with all uppercase letters replaced with their lowercase counterparts. The operation is locale insensitive—only characters"A" to"Z" are affected. Note: case replacement is effective only in ASCII region.

请参阅这个问题以正确的小写utf-8字符串ruby 1.9:如何正确地大写和小写多字节字符串?