245 static const char hexDigits[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F' };
246 static const char escape[256] = {
247 #define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
249 'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'b',
't',
'n',
'u',
'f',
'r',
'u',
'u',
250 'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
'u',
251 0, 0,
'"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
253 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
'\\', 0, 0, 0,
260 while (is.Tell() <
length) {
261 const Ch c = is.Peek();
262 if (!TargetEncoding::supportUnicode && (
unsigned)c >= 0x80) {
265 if (!SourceEncoding::Decode(is, &codepoint))
269 if (codepoint <= 0xD7FF || (codepoint >= 0xE000 && codepoint <= 0xFFFF)) {
270 os_->Put(hexDigits[(codepoint >> 12) & 15]);
271 os_->Put(hexDigits[(codepoint >> 8) & 15]);
272 os_->Put(hexDigits[(codepoint >> 4) & 15]);
273 os_->Put(hexDigits[(codepoint ) & 15]);
278 unsigned s = codepoint - 0x010000;
279 unsigned lead = (s >> 10) + 0xD800;
280 unsigned trail = (s & 0x3FF) + 0xDC00;
281 os_->Put(hexDigits[(lead >> 12) & 15]);
282 os_->Put(hexDigits[(lead >> 8) & 15]);
283 os_->Put(hexDigits[(lead >> 4) & 15]);
284 os_->Put(hexDigits[(lead ) & 15]);
287 os_->Put(hexDigits[(trail >> 12) & 15]);
288 os_->Put(hexDigits[(trail >> 8) & 15]);
289 os_->Put(hexDigits[(trail >> 4) & 15]);
290 os_->Put(hexDigits[(trail ) & 15]);
293 else if ((
sizeof(
Ch) == 1 || (
unsigned)c < 256) && escape[(
unsigned char)c]) {
296 os_->Put(escape[(
unsigned char)c]);
297 if (escape[(
unsigned char)c] ==
'u') {
300 os_->Put(hexDigits[(
unsigned char)c >> 4]);
301 os_->Put(hexDigits[(
unsigned char)c & 0xF]);
Encoding conversion.
Definition: encodings.h:586
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
Read-only string stream.
Definition: rapidjson.h:571
SourceEncoding::Ch Ch
Definition: writer.h:56
OutputStream * os_
Definition: writer.h:337
float length(float v)
Definition: vectorMath.h:208
static std::string escape(const std::string &string)
Definition: TextOutput.cpp:77