@@ -59,7 +59,7 @@ literals = mkPattern' match'
61 objectPropertyToString :: (Emit gen) => Text -> gen
61 objectPropertyToString :: (Emit gen) => Text -> gen
62โ objectPropertyToString s | identNeedsEscaping s = emit $ T.pack $ show s
62+ objectPropertyToString s | identNeedsEscaping s = string s
63 | otherwise = emit s
63 | otherwise = emit s
64 match (JSBlock _ sts) = mconcat <$> sequence
64 match (JSBlock _ sts) = mconcat <$> sequence
65 [ return $ emit "{\n"
65 [ return $ emit "{\n"
@@ -162,11 +162,9 @@ string s = emit $ "\"" <> T.concatMap encodeChar s <> "\""
162 encodeChar '\r' = "\\r"
162 encodeChar '\r' = "\\r"
163 encodeChar '"' = "\\\""
163 encodeChar '"' = "\\\""
164 encodeChar '\\' = "\\\\"
164 encodeChar '\\' = "\\\\"
165+ -- PureScript strings are sequences of UTF-16 code units, so this case should never be hit.
166+ -- If it is somehow hit, though, output the designated Unicode replacement character U+FFFD.
165โ encodeChar c | fromEnum c > 0xFFFF = "\\u" <> showHex' highSurrogate ("\\u" ++ showHex lowSurrogate "")
167+ encodeChar c | fromEnum c > 0xFFFF = "\\uFFFD"
167โ (h, l) = divMod (fromEnum c - 0x10000) 0x400
168โ highSurrogate = h + 0xD800
169โ lowSurrogate = l + 0xDC00
170 encodeChar c | fromEnum c > 0xFFF = "\\u" <> showHex' (fromEnum c) ""
168 encodeChar c | fromEnum c > 0xFFF = "\\u" <> showHex' (fromEnum c) ""
171 encodeChar c | fromEnum c > 0xFF = "\\u0" <> showHex' (fromEnum c) ""
169 encodeChar c | fromEnum c > 0xFF = "\\u0" <> showHex' (fromEnum c) ""
172 encodeChar c | fromEnum c < 0x10 = "\\x0" <> showHex' (fromEnum c) ""
170 encodeChar c | fromEnum c < 0x10 = "\\x0" <> showHex' (fromEnum c) ""