on master help sign in
Merge pull request #1785 from raichoo/master

javascript

commite6dcf41ffdc4d366d41377d332edbd6f9d5256c8 authorraichoo <raichoo@googlemail.com> dateSat 13 Dec 2014, 14:44 (12 years ago) parentb9e5895d176363
3 files changed+10−6
CHANGELOG+1 idris.cabal+2−2 src/IRTS/CodegenJavaScript.hs+7−4
CHANGELOG+1
@@ -5,6 +5,7 @@ New in 0.9.16:
55* A new tactic sourceLocation that fills the current hole with the current
66 source code span, if this information is available. If not, it raises an
77 error.
8+* Better Unicode support for the JavaScript/Node codegen
89
910New in 0.9.15:
1011--------------
idris.cabal+2−2
@@ -804,7 +804,7 @@ Executable idris-javascript
804804 , transformers
805805
806806 ghc-prof-options: -auto-all -caf-all
807− ghc-options: -threaded -rtsopts -funbox-strict-fields
807+ ghc-options: -threaded -rtsopts -funbox-strict-fields -O2
808808
809809Executable idris-node
810810 Main-is: Main.hs
@@ -817,4 +817,4 @@ Executable idris-node
817817 , transformers
818818
819819 ghc-prof-options: -auto-all -caf-all
820− ghc-options: -threaded -rtsopts -funbox-strict-fields
820+ ghc-options: -threaded -rtsopts -funbox-strict-fields -O2
src/IRTS/CodegenJavaScript.hs+7−4
@@ -495,13 +495,16 @@ translateChar ch
495495 | '\\' <- ch = "\\\\"
496496 | '\"' <- ch = "\\\""
497497 | '\'' <- ch = "\\\'"
498− | ch `elem` asciiTab = "\\u00" ++ fill (showHex (ord ch) "")
498+ | ch `elem` asciiTab = "\\u" ++ fill (showHex (ord ch) "")
499+ | ord ch > 255 = "\\u" ++ fill (showHex (ord ch) "")
499500 | otherwise = [ch]
500501 where
501502 fill :: String -> String
502− fill s = if length s == 1
503− then '0' : s
504− else s
503+ fill s = case length s of
504+ 1 -> "000" ++ s
505+ 2 -> "00" ++ s
506+ 3 -> "0" ++ s
507+ _ -> s
505508
506509 asciiTab =
507510 ['\NUL', '\SOH', '\STX', '\ETX', '\EOT', '\ENQ', '\ACK', '\BEL',