Advertisement
Guest User

Untitled

a guest
Aug 5th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.35 KB | None | 0 0
  1. import unicode
  2.  
  3. type
  4.   UTF16String* = seq[Rune16]
  5.  
  6. proc utf16*(s: string): UTF16String {.inline.} =
  7.   result = @[]
  8.   for i in s:
  9.     result.add(Rune16(i))
  10.  
  11. proc `$`*(self: UTF16String): string =
  12.   result = ""
  13.   for i in self:
  14.     if (int(i) and 0xFF00) != 0: result = result & chr(int(i) and 0xFF00)
  15.     result = result & chr(int(i) and 0xFF)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement