ghcjs / ghcjs-base

base library for GHCJS for JavaScript interaction and marshalling, used by higher level libraries like JSC
MIT License
45 stars 67 forks source link

JSString.intersperse does not handle astral chars correctly #117

Closed luigy closed 5 years ago

luigy commented 6 years ago
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.List as L
import qualified Data.JSString as String

main :: IO ()
main = do
  let s = "abc"
      ch = '\285026'
      r = String.intersperse ch (String.pack s)
  putStrLn $ show (L.intersperse ch s) ++ " <> " ++ show (String.unpack r) -- "a\285026b\285026c" <> "a\56534\55650b\56534\55650c"
  print $ L.intersperse ch s == String.unpack r -- false
luite commented 5 years ago

thanks for the fix