import std/unicode
let str = “你好/hi”
for c in str.runes():
case c:
of '/': # compile error here, since c is type of distinct RuneImpl
echo " '/' found"
break
Please stop repeatedly creating new threads and deleting old ones. The forum has edit functionality. As for your question, use the utf8 iterator to iterate over runes as strings:
import std/unicode
let str = "你好/hi"
for c in str.utf8():
case c
of "/":
echo " '/' found"
break
thanks a lot ;-)
There is always a problem with the code snippet render. I have to use pictures, and then it becomes normal again.
You can also use:
import std/unicode
let str = "你好/hi"
for c in str.runes():
case c:
of Rune('/'):
echo " '/' found"
break
else:
discard
Also, you have to add some text to the post in addition to the code snippet, or it'll not be rendered.