valderman / haste-compiler

A GHC-based Haskell to JavaScript compiler
http://haste-lang.org
BSD 3-Clause "New" or "Revised" License
1.45k stars 115 forks source link

Characters truncated to 16 bits #388

Open WolframKahl opened 7 years ago

WolframKahl commented 7 years ago

With the current version of Haste, the 𝔹 loses its 17th bit:

{-# LANGUAGE StaticPointers, OverloadedStrings #-}
import Haste.App.Simple
import qualified Haste.JSString as JSS

main = runSimpleApp $ do
  p <- newElem "p"
  t <- newTextElem (JSS.pack $ "The set of Booleans is written 𝔹.")
  setChildren p [t]
  appendChild documentBody p

The resulting page shows:

The set of Booleans is written 픹.

𝔹 is codepoint 0x1d539, and is codepoint 0xd539.

WolframKahl commented 7 years ago

(--full-unicode and --opt-all do not make a difference.)

valderman commented 7 years ago

Good catch. pack currently works pretty much like Data.ByteString.pack, but there's no compelling reason why it shouldn't be smarter.