zwilias/elm-utf-tools/2.0.1

String.UTF16

For some reason want to reason about strings as if they were UTF-16 sequences?

Technically, that's what they are, but Elm allows treating them as Unicode codepoints, which is super-convenient. Occasionally, however, you may find yourself in need of some old fashioned UTF-16 bytes, so here you go!

length : String -> Int

Count the number of UTF-16 bytes in a String.

Note that this should always equal String.length in Elm.

toBytes : String -> List Int

Turn a String into a list of UTF-16 bytes.

toString : List Int -> String

Turn a list of UTF-16 bytes into a String.

foldl : (Int -> acc -> acc) -> acc -> String -> acc