Hello,

i need unicode codes of any char in a string, but i dont get it. Can someone 
give me some clarity about unicodes in nim?

This is what i tried to understand them:
    
    
    import
      strutils,
      unicode
    
    proc getUnicode(c: string) =
      let runeLen = c.runeLenAt(0)
      echo "Length of " & $c & " is: " & $runeLen
      
      for i in 0..<runeLen:
        echo c[i].uint.toHex()
    
    getUnicode("a") # gives "61" which is right
    getUnicode("°") # gives "C2" and "B0", but only "B0" is '°'.
    getUnicode("€") # gives "E2", "82" and "AC", but the unicode of '€' is 
"20AC".
    
    
    Run

Reply via email to