From 8e998f7d96d3236e182ea54cc077f87538651af3 Mon Sep 17 00:00:00 2001 From: fab Date: Thu, 6 Dec 2018 21:59:47 +0000 Subject: ord --- lib/js/urweb.js | 2 +- tests/utf8.ur | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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"} + @@ -471,6 +477,11 @@ fun test_ords () : transaction page = return {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"} end -- cgit v1.2.3