在Julia中获取UTF-8子串的最简单方法是什么(What is the simplest way to get UTF-8 substring in Julia)
Julia中的UTF-8字符串不能使用切片运算符,因为它切换字符串的字节索引而不是字符。 例如
s = "ポケットモンスター" s[1:4]s [1:4]将是“ポケ”而不是“ポケット”。
我想知道Julia中获取UTF-8子字符串的最简单和最可读。
UTF-8 string in Julia cannot use slice operator because it slice the byte index of string not character. For example
s = "ポケットモンスター" s[1:4]s[1:4] will be "ポケ" not "ポケット".
I would like to know the simplest and most readable for get UTF-8 sub-string in Julia.
最满意答案
您可能需要考虑使用UTF32String而不是UTF8String ,如果您要执行此操作,并且在完成时仅在必要时转换为UTF8String 。
You might want to consider using UTF32String instead of UTF8String, if you are going to be doing this a lot, and only converting to UTF8String if necessary, when you are finished.
更多推荐
发布评论