diff options
-rw-r--r-- | lib/js/urweb.js | 2 | ||||
-rw-r--r-- | tests/utf8.ur | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 2b34f8dd..18d47847 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -35,7 +35,7 @@ function isAlnum(c) { return isAlpha(c) || isDigit(c); } function isBlank(c) { return c == ' ' || c == '\t'; } function isSpace(c) { return isBlank(c) || c == '\r' || c == '\n'; } function isXdigit(c) { return isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); } -function ord(c) { return c.charCodeAt(0); } +function ord(c) { return c.codePointAt(0); } function isPrint(c) { return ord(c) > 31 && ord(c) != 127; } function toLower(c) { return c.toLowerCase(); } function toUpper(c) { diff --git a/tests/utf8.ur b/tests/utf8.ur index b1507285..b519b615 100644 --- a/tests/utf8.ur +++ b/tests/utf8.ur @@ -68,6 +68,12 @@ fun highencode () : transaction page = {test_fn_cside (fn _ => strindex "๐๐๐๐" (strsub "๐" 0)) (strindex "๐๐๐๐" (strsub "๐" 0)) "high encode - strindex 3"} {test_fn_cside (fn _ => strindex "๐๐๐๐" (strsub "๐" 0)) (strindex "๐๐๐๐" (strsub "๐" 0)) "high encode - strindex 4"} {test_fn_cside (fn _ => strindex "๐๐๐๐" (strsub "๐" 0)) (strindex "๐๐๐๐" (strsub "๐" 0)) "high encode - strindex 5"} + + {test_fn_cside (fn _ => ord (strsub "๐๐๐๐" 0)) (ord (strsub "๐๐๐๐" 0)) "high encode - ord 1"} + {test_fn_cside (fn _ => ord (strsub "๐๐๐๐" 1)) (ord (strsub "๐๐๐๐" 1)) "high encode - ord 2"} + {test_fn_cside (fn _ => ord (strsub "๐๐๐๐" 2)) (ord (strsub "๐๐๐๐" 2)) "high encode - ord 3"} + {test_fn_cside (fn _ => ord (strsub "๐๐๐๐" 3)) (ord (strsub "๐๐๐๐" 3)) "high encode - ord 4"} + </body> </xml> @@ -471,6 +477,11 @@ fun test_ords () : transaction page = return <xml> <body> {test_fn_cside (ord_of (strsub "a" 0)) (ord_of (strsub "a" 0) ()) "test ord 1"} + {test_fn_cside (ord_of (strsub "รก" 0)) (ord_of (strsub "รก" 0) ()) "test ord 2"} + {test_fn_cside (ord_of (strsub "5" 0)) (ord_of (strsub "5" 0) ()) "test ord 3"} + {test_fn_cside (ord_of (strsub "ใ" 0)) (ord_of (strsub "ใ" 0) ()) "test ord 4"} + {test_fn_cside (ord_of (strsub "ๆผข" 0)) (ord_of (strsub "ๆผข" 0) ()) "test ord 5"} + {test_fn_cside (ord_of (strsub "ใซ" 0)) (ord_of (strsub "ใซ" 0) ()) "test ord 6"} </body> </xml> end |