From 8dbc107441194238267a94aaa46248c405c2159c Mon Sep 17 00:00:00 2001 From: Tae-il Lim Date: Sun, 3 Apr 2016 17:08:23 +0900 Subject: [PATCH 1/2] Tweak unicode-escape test --- tests/valid/unicode-escape.json | 4 ++-- tests/valid/unicode-escape.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/valid/unicode-escape.json b/tests/valid/unicode-escape.json index 216f8f7..8c09dc0 100644 --- a/tests/valid/unicode-escape.json +++ b/tests/valid/unicode-escape.json @@ -1,4 +1,4 @@ { - "answer4": {"type": "string", "value": "\u03B4"}, - "answer8": {"type": "string", "value": "\u03B4"} + "answer4": {"type": "string", "value": "\u03B4α"}, + "answer8": {"type": "string", "value": "\u03B4β"} } diff --git a/tests/valid/unicode-escape.toml b/tests/valid/unicode-escape.toml index 82faecb..20198f4 100644 --- a/tests/valid/unicode-escape.toml +++ b/tests/valid/unicode-escape.toml @@ -1,2 +1,2 @@ -answer4 = "\u03B4" -answer8 = "\U000003B4" +answer4 = "\u03B4α" +answer8 = "\U000003B4β" From 6426b02d3ddce39a2a3c2b34a0292b2d980e64ab Mon Sep 17 00:00:00 2001 From: Tae-il Lim Date: Sun, 3 Apr 2016 17:15:18 +0900 Subject: [PATCH 2/2] Use different method to ensure unicode escape code is ASCII of expected length --- src/parser.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 9eb506a..2a156e3 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,4 +1,3 @@ -use std::ascii::AsciiExt; use std::char; use std::collections::BTreeMap; use std::error::Error; @@ -490,7 +489,7 @@ impl<'a> Parser<'a> { Some((pos, c @ 'U')) => { let len = if c == 'u' {4} else {8}; let num = &me.input[pos+1..]; - let num = if num.len() >= len && num.is_ascii() { + let num = if num.char_indices().nth(len).map(|(i, _)| i).unwrap_or(0) == len { &num[..len] } else { "invalid"