gpt4 book ai didi

unicode - ContainsRune 给出奇怪的结果

转载 作者:IT王子 更新时间:2023-10-29 01:20:20 24 4
gpt4 key购买 nike

我在 Go Playground 中运行这段代码:

fmt.Println(strings.ContainsRune("\xa0", '\xa0'))

我想知道,为什么会输出false?根据docs ,它说:

ContainsRune returns true if the Unicode code point r is within s.

在我看来代码点就在那里,它会给出 false 作为响应似乎很奇怪。

最佳答案

"\x0a"不是 unicode 代码点。

fmt.Println(strings.ContainsRune("\u00a0", '\u00a0'))

按预期工作。

关于unicode - ContainsRune 给出奇怪的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25775022/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com