我正在玩Golang并发现了这个问题。我可以使用以下代码来获取基于字节的索引:
strings.Index("您好你好", "你好")
我得到的是6,它基于字节计数。
如果我们依靠符文(字符),我们应该得到2这就是我想要的。我怎样才能得到我想要的东西?
感谢。
答案 0 :(得分:4)
您可以使用utf8.RuneCountInString()
方法:
https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&redirect_uri=https%3A%2F%2Fl.xxxxxx.com%3A50000%2Fauth%2Fmicrosoft_graph%2Fcallback&client_id=xxxxxx-xxx-xxx-xxx-xxxx&scope=https%3A%2F%2Fgraph.microsoft.com%2Femail%20https%3A%2F%2Fgraph.microsoft.com%2Fprofile%20https%3A%2F%2Fgraph.microsoft.com%2FUser.Read%20https%3A%2F%2Fgraph.microsoft.com%2FUser.ReadBasic.All%20https%3A%2F%2Fgraph.microsoft.com%2FGroup.Read.All