在Julia中获取UTF

编程入门 行业动态 更新时间:2024-10-22 17:31:38
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.

更多推荐

本文发布于:2023-08-04 09:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1415168.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Julia   UTF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!