2 回答

TA貢獻1826條經驗 獲得超6個贊
是的,這是“正確”的行為。這些字母在大小寫折疊下表現不正常。見: http ://www.unicode.org/Public/UCD/latest/ucd/CaseFolding.txt
U+0131 有全箱折疊“F”和特殊“T”:
T: special case for uppercase I and dotted uppercase I
- For non-Turkic languages, this mapping is normally not used.
- For Turkic languages (tr, az), this mapping can be used instead
of the normal mapping for these characters.
Note that the Turkic mappings do not maintain canonical equivalence
without additional processing.
See the discussions of case mapping in the Unicode Standard for more information.
我認為沒有辦法強制包字符串使用 tr 或 az 映射。

TA貢獻1719條經驗 獲得超6個贊
來自strings.EqualFold源 -unicode.ToLower
并且unicode.ToUpper
未使用。
相反,它使用unicode.SimpleFold來查看特定符文是否“可折疊”,因此可能具有可比性:
// General case. SimpleFold(x) returns the next equivalent rune > x
// or wraps around to smaller values.
r := unicode.SimpleFold(sr)
for r != sr && r < tr {
r = unicode.SimpleFold(r)
}
符文?不可折疊。它的小寫代碼點是:
r := rune(0x0130) // U+0130 '?'
lr := unicode.ToLower(r) // U+0069 'i'
fmt.Printf("foldable? %v\n", r != unicode.SimpleFold(r)) // foldable? false
fmt.Printf("foldable? %v\n", lr != unicode.SimpleFold(lr)) // foldable? true
如果符文不可折疊(即SimpleFold返回自身) - 那么該符文只能匹配自身而不能匹配其他代碼點。
https://play.golang.org/p/105x0I714nS
- 2 回答
- 0 關注
- 163 瀏覽
添加回答
舉報