mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 16:01:42 +12:00
Added simple keys.
There's a bug (and question): should we test simple keys' validity BEFORE stuff or AFTER stuff?
This commit is contained in:
parent
49a75b2d78
commit
11706abbb7
9 changed files with 321 additions and 79 deletions
66
exp.cpp
66
exp.cpp
|
@ -46,18 +46,18 @@ namespace YAML
|
|||
unsigned value = ParseHex(str);
|
||||
|
||||
// legal unicode?
|
||||
if((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF)
|
||||
throw InvalidUnicode(value);
|
||||
|
||||
// now break it up into chars
|
||||
if(value <= 0x7F)
|
||||
return Str(value);
|
||||
else if(value <= 0x7FF)
|
||||
return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F));
|
||||
else if(value <= 0xFFFF)
|
||||
return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F));
|
||||
else
|
||||
return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) +
|
||||
if((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF)
|
||||
throw InvalidUnicode(value);
|
||||
|
||||
// now break it up into chars
|
||||
if(value <= 0x7F)
|
||||
return Str(value);
|
||||
else if(value <= 0x7FF)
|
||||
return Str(0xC0 + (value >> 6)) + Str(0x80 + (value & 0x3F));
|
||||
else if(value <= 0xFFFF)
|
||||
return Str(0xE0 + (value >> 12)) + Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F));
|
||||
else
|
||||
return Str(0xF0 + (value >> 18)) + Str(0x80 + ((value >> 12) & 0x3F)) +
|
||||
Str(0x80 + ((value >> 6) & 0x3F)) + Str(0x80 + (value & 0x3F));
|
||||
}
|
||||
|
||||
|
@ -76,27 +76,27 @@ namespace YAML
|
|||
|
||||
// switch on escape character
|
||||
char ch = in.get();
|
||||
switch(ch) {
|
||||
case '0': return "\0";
|
||||
case 'a': return "\x07";
|
||||
case 'b': return "\x08";
|
||||
case 't':
|
||||
case '\t': return "\x09";
|
||||
case 'n': return "\x0A";
|
||||
case 'v': return "\x0B";
|
||||
case 'f': return "\x0C";
|
||||
case 'r': return "\x0D";
|
||||
case 'e': return "\x1B";
|
||||
case ' ': return "\x20";
|
||||
case '\"': return "\"";
|
||||
case '\'': return "\'";
|
||||
case '\\': return "\\";
|
||||
case 'N': return "\xC2\x85"; // NEL (#x85)
|
||||
case '_': return "\xC2\xA0"; // #xA0
|
||||
case 'L': return "\xE2\x80\xA8"; // LS (#x2028)
|
||||
case 'P': return "\xE2\x80\xA9"; // PS (#x2029)
|
||||
case 'x': return Escape(in, length, 2);
|
||||
case 'u': return Escape(in, length, 4);
|
||||
switch(ch) {
|
||||
case '0': return "\0";
|
||||
case 'a': return "\x07";
|
||||
case 'b': return "\x08";
|
||||
case 't':
|
||||
case '\t': return "\x09";
|
||||
case 'n': return "\x0A";
|
||||
case 'v': return "\x0B";
|
||||
case 'f': return "\x0C";
|
||||
case 'r': return "\x0D";
|
||||
case 'e': return "\x1B";
|
||||
case ' ': return "\x20";
|
||||
case '\"': return "\"";
|
||||
case '\'': return "\'";
|
||||
case '\\': return "\\";
|
||||
case 'N': return "\xC2\x85"; // NEL (#x85)
|
||||
case '_': return "\xC2\xA0"; // #xA0
|
||||
case 'L': return "\xE2\x80\xA8"; // LS (#x2028)
|
||||
case 'P': return "\xE2\x80\xA9"; // PS (#x2029)
|
||||
case 'x': return Escape(in, length, 2);
|
||||
case 'u': return Escape(in, length, 4);
|
||||
case 'U': return Escape(in, length, 8);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue