EncodeStringUnicodeTest
`Bytes.Encode.string` writes a string as UTF-8, so a two-byte character takes two bytes. The test encodes three copies of `é` (U+00E9) and logs the width of the result, 6.
Results
elm-0.19.1
passran in 65 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets. EncodeStringUnicodeTest: 6
elm-0.19.2
passran in 51 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.2/optimize for better performance and smaller assets. EncodeStringUnicodeTest: 6
elm-0.19.3
passran in 67 msOutput
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.3/optimize for better performance and smaller assets. EncodeStringUnicodeTest: 6
lamdera-1.5.0
passran in 64 msOutput
EncodeStringUnicodeTest: 6
Discussions
Discuss this test·Search the discussions on GitHub
Discussions are on GitHub; one about this test has [t:elm-bytes/EncodeStringUnicodeTest] in its title.
Source
The -- CHECK: lines give the expected output.
module EncodeStringUnicodeTest exposing (main)
{-| `Bytes.Encode.string` writes a string as UTF-8, so a two-byte character takes two bytes.
The test encodes three copies of `é` (U+00E9) and logs the width of the result, 6.
-}
-- CHECK: EncodeStringUnicodeTest: 6
import Bytes exposing (Bytes)
import Bytes.Encode as E
import Html exposing (text)
main =
let
bytes =
E.encode (E.string "\u{00E9}\u{00E9}\u{00E9}")
result =
Bytes.width bytes
_ =
Debug.log "EncodeStringUnicodeTest" result
in
text (String.fromInt result)