Test \u handling
| 137 | |
| 138 | // Test \u handling |
| 139 | void unescape_unicode_test() |
| 140 | { |
| 141 | UniValue val; |
| 142 | bool testResult; |
| 143 | // Escaped ASCII (quote) |
| 144 | testResult = val.read("[\"\\u0022\"]"); |
| 145 | f_assert(testResult); |
| 146 | f_assert(val[0].get_str() == "\""); |
| 147 | // Escaped Basic Plane character, two-byte UTF-8 |
| 148 | testResult = val.read("[\"\\u0191\"]"); |
| 149 | f_assert(testResult); |
| 150 | f_assert(val[0].get_str() == "\xc6\x91"); |
| 151 | // Escaped Basic Plane character, three-byte UTF-8 |
| 152 | testResult = val.read("[\"\\u2191\"]"); |
| 153 | f_assert(testResult); |
| 154 | f_assert(val[0].get_str() == "\xe2\x86\x91"); |
| 155 | // Escaped Supplementary Plane character U+1d161 |
| 156 | testResult = val.read("[\"\\ud834\\udd61\"]"); |
| 157 | f_assert(testResult); |
| 158 | f_assert(val[0].get_str() == "\xf0\x9d\x85\xa1"); |
| 159 | } |
| 160 | |
| 161 | int main (int argc, char *argv[]) |
| 162 | { |