mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40:20 +03:00
Fix for bugzilla 5366
This commit is contained in:
parent
461e22c923
commit
9f51068a74
1 changed files with 9 additions and 1 deletions
10
std/json.d
10
std/json.d
|
@ -156,7 +156,7 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T) {
|
|||
foreach_reverse(i; 0 .. 4) {
|
||||
auto hex = toupper(getChar());
|
||||
if(!isxdigit(hex)) error("Expecting hex character");
|
||||
val += (isdigit(hex) ? hex - '0' : hex - 'A') << (4 * i);
|
||||
val += (isdigit(hex) ? hex - '0' : hex - ('A' - 10)) << (4 * i);
|
||||
}
|
||||
char[4] buf = void;
|
||||
str.put(toUTF8(buf, val));
|
||||
|
@ -461,4 +461,12 @@ unittest {
|
|||
writefln(text(json, "\n", e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// Should be able to correctly interpret unicode entities
|
||||
val = parseJSON(`"\u003C\u003E"`);
|
||||
assert(toJSON(&val) == "\"\<\>\"");
|
||||
val = parseJSON(`"\u0391\u0392\u0393"`);
|
||||
assert(toJSON(&val) == "\"\Α\Β\Γ\"");
|
||||
val = parseJSON(`"\u2660\u2666"`);
|
||||
assert(toJSON(&val) == "\"\♠\♦\"");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue