miniBill/elm-utf-tools/1.0.0

String.UTF32

Need to work in unicode codepoints? Tired of UTF-8's silliness? You came to the right place!

length : String -> Int

Calculates the number UTF-32 characters in a String.

import String.UTF32 as UTF32


String.length "💩"
--> 2


UTF32.length "💩"
--> 1
fromList : List Int -> String

Build a String from a list of unicode codepoints.

import String.UTF32 as UTF32


UTF32.fromList [ 0x68, 0x65, 0x6C, 0x6C, 0x6F ]
--> "hello"


UTF32.fromList [ 0x0001F4A9 ]
--> "💩"
toList : String -> List Int

Converts a String to a list of unicode codepoints. The inverse of toString

import String.UTF32 as UTF32


UTF32.toList "hello"
--> [ 0x68, 0x65, 0x6C, 0x6C, 0x6F ]


UTF32.toList "💩"
--> [ 0x0001F4A9 ]