15#ifndef RAPIDJSON_ENCODINGS_H_
16#define RAPIDJSON_ENCODINGS_H_
20#if defined(_MSC_VER) && !defined(__clang__)
22RAPIDJSON_DIAG_OFF(4244)
23RAPIDJSON_DIAG_OFF(4702)
24#elif defined(__GNUC__)
26RAPIDJSON_DIAG_OFF(effc++)
27RAPIDJSON_DIAG_OFF(overflow)
48 template<typename OutputStream>
49 static void Encode(OutputStream& os, unsigned codepoint);
55 template <typename InputStream>
56 static bool Decode(InputStream& is, unsigned* codepoint);
63 template <typename InputStream, typename OutputStream>
64 static bool Validate(InputStream& is, OutputStream& os);
66 // The following functions are deal with byte streams.
69 template <typename InputByteStream>
70 static CharType TakeBOM(InputByteStream& is);
73 template <typename InputByteStream>
74 static Ch Take(InputByteStream& is);
77 template <typename OutputByteStream>
78 static void PutBOM(OutputByteStream& os);
81 template <typename OutputByteStream>
82 static void Put(OutputByteStream& os, Ch c);
96template <
typename CharType =
char>
106 template <
typename OutputStream>
107 static void Encode(OutputStream& os,
unsigned codepoint)
109 if(codepoint <= 0x7F)
110 os.Put(
static_cast<Ch>(codepoint & 0xFF));
111 else if(codepoint <= 0x7FF)
113 os.Put(
static_cast<Ch>(0xC0 | ((codepoint >> 6) & 0xFF)));
114 os.Put(
static_cast<Ch>(0x80 | ((codepoint & 0x3F))));
116 else if(codepoint <= 0xFFFF)
118 os.Put(
static_cast<Ch>(0xE0 | ((codepoint >> 12) & 0xFF)));
119 os.Put(
static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));
120 os.Put(
static_cast<Ch>(0x80 | (codepoint & 0x3F)));
125 os.Put(
static_cast<Ch>(0xF0 | ((codepoint >> 18) & 0xFF)));
126 os.Put(
static_cast<Ch>(0x80 | ((codepoint >> 12) & 0x3F)));
127 os.Put(
static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));
128 os.Put(
static_cast<Ch>(0x80 | (codepoint & 0x3F)));
132 template <
typename OutputStream>
135 if(codepoint <= 0x7F)
137 else if(codepoint <= 0x7FF)
139 PutUnsafe(os,
static_cast<Ch>(0xC0 | ((codepoint >> 6) & 0xFF)));
140 PutUnsafe(os,
static_cast<Ch>(0x80 | ((codepoint & 0x3F))));
142 else if(codepoint <= 0xFFFF)
144 PutUnsafe(os,
static_cast<Ch>(0xE0 | ((codepoint >> 12) & 0xFF)));
145 PutUnsafe(os,
static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));
146 PutUnsafe(os,
static_cast<Ch>(0x80 | (codepoint & 0x3F)));
151 PutUnsafe(os,
static_cast<Ch>(0xF0 | ((codepoint >> 18) & 0xFF)));
152 PutUnsafe(os,
static_cast<Ch>(0x80 | ((codepoint >> 12) & 0x3F)));
153 PutUnsafe(os,
static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));
154 PutUnsafe(os,
static_cast<Ch>(0x80 | (codepoint & 0x3F)));
158 template <
typename InputStream>
159 static bool Decode(InputStream& is,
unsigned* codepoint)
161#define RAPIDJSON_COPY() \
163 *codepoint = (*codepoint << 6) | (static_cast<unsigned char>(c) & 0x3Fu)
164#define RAPIDJSON_TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)
165#define RAPIDJSON_TAIL() \
167 RAPIDJSON_TRANS(0x70)
168 typename InputStream::Ch c = is.Take();
171 *codepoint =
static_cast<unsigned char>(c);
175 unsigned char type =
GetRange(
static_cast<unsigned char>(c));
182 *codepoint = (0xFFu >> type) &
static_cast<unsigned char>(c);
219 default:
return false;
222#undef RAPIDJSON_TRANS
226 template <
typename InputStream,
typename OutputStream>
227 static bool Validate(InputStream& is, OutputStream& os)
229#define RAPIDJSON_COPY() \
231 os.Put(c = is.Take())
232#define RAPIDJSON_TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)
233#define RAPIDJSON_TAIL() \
235 RAPIDJSON_TRANS(0x70)
236 Ch c =
static_cast<Ch>(-1);
242 switch(
GetRange(
static_cast<unsigned char>(c)))
276 default:
return false;
279#undef RAPIDJSON_TRANS
288 static const unsigned char type[] = {
289 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
290 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
291 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
292 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
293 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
294 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
295 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
296 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
298 0, 0, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
299 0x10, 0x10, 0x10, 0x10, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
300 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
301 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
302 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 8, 8, 2, 2,
303 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
304 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
305 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4,
306 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8, 8, 8,
312 template <
typename InputByteStream>
316 typename InputByteStream::Ch c =
Take(is);
317 if(
static_cast<unsigned char>(c) != 0xEFu)
320 if(
static_cast<unsigned char>(c) != 0xBBu)
323 if(
static_cast<unsigned char>(c) != 0xBFu)
329 template <
typename InputByteStream>
333 return static_cast<Ch>(is.Take());
336 template <
typename OutputByteStream>
340 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xEFu));
341 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xBBu));
342 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xBFu));
345 template <
typename OutputByteStream>
346 static void Put(OutputByteStream& os,
Ch c)
349 os.Put(
static_cast<typename OutputByteStream::Ch
>(c));
365template <
typename CharType =
wchar_t>
376 template <
typename OutputStream>
377 static void Encode(OutputStream& os,
unsigned codepoint)
380 if(codepoint <= 0xFFFF)
384 os.Put(
static_cast<typename OutputStream::Ch
>(codepoint));
389 unsigned v = codepoint - 0x10000;
390 os.Put(
static_cast<typename OutputStream::Ch
>((v >> 10) | 0xD800));
391 os.Put(
static_cast<typename OutputStream::Ch
>((v & 0x3FF) | 0xDC00));
395 template <
typename OutputStream>
399 if(codepoint <= 0xFFFF)
403 PutUnsafe(os,
static_cast<typename OutputStream::Ch
>(codepoint));
408 unsigned v = codepoint - 0x10000;
409 PutUnsafe(os,
static_cast<typename OutputStream::Ch
>((v >> 10) | 0xD800));
410 PutUnsafe(os,
static_cast<typename OutputStream::Ch
>((v & 0x3FF) | 0xDC00));
414 template <
typename InputStream>
415 static bool Decode(InputStream& is,
unsigned* codepoint)
418 typename InputStream::Ch c = is.Take();
419 if(c < 0xD800 || c > 0xDFFF)
421 *codepoint =
static_cast<unsigned>(c);
426 *codepoint = (
static_cast<unsigned>(c) & 0x3FF) << 10;
428 *codepoint |= (
static_cast<unsigned>(c) & 0x3FF);
429 *codepoint += 0x10000;
430 return c >= 0xDC00 && c <= 0xDFFF;
435 template <
typename InputStream,
typename OutputStream>
436 static bool Validate(InputStream& is, OutputStream& os)
440 typename InputStream::Ch c;
441 os.Put(
static_cast<typename OutputStream::Ch
>(c = is.Take()));
442 if(c < 0xD800 || c > 0xDFFF)
446 os.Put(c = is.Take());
447 return c >= 0xDC00 && c <= 0xDFFF;
454template <
typename CharType =
wchar_t>
457 template <
typename InputByteStream>
461 CharType c =
Take(is);
462 return static_cast<uint16_t>(c) == 0xFEFFu ?
Take(is) : c;
465 template <
typename InputByteStream>
466 static CharType
Take(InputByteStream& is)
469 unsigned c =
static_cast<uint8_t>(is.Take());
470 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 8;
471 return static_cast<CharType
>(c);
474 template <
typename OutputByteStream>
478 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFFu));
479 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFEu));
482 template <
typename OutputByteStream>
483 static void Put(OutputByteStream& os, CharType c)
486 os.Put(
static_cast<typename OutputByteStream::Ch
>(
static_cast<unsigned>(c) & 0xFFu));
487 os.Put(
static_cast<typename OutputByteStream::Ch
>((
static_cast<unsigned>(c) >> 8) & 0xFFu));
492template <
typename CharType =
wchar_t>
495 template <
typename InputByteStream>
499 CharType c =
Take(is);
500 return static_cast<uint16_t>(c) == 0xFEFFu ?
Take(is) : c;
503 template <
typename InputByteStream>
504 static CharType
Take(InputByteStream& is)
507 unsigned c =
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 8;
508 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take()));
509 return static_cast<CharType
>(c);
512 template <
typename OutputByteStream>
516 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFEu));
517 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFFu));
520 template <
typename OutputByteStream>
521 static void Put(OutputByteStream& os, CharType c)
524 os.Put(
static_cast<typename OutputByteStream::Ch
>((
static_cast<unsigned>(c) >> 8) & 0xFFu));
525 os.Put(
static_cast<typename OutputByteStream::Ch
>(
static_cast<unsigned>(c) & 0xFFu));
540template <
typename CharType =
unsigned>
551 template <
typename OutputStream>
552 static void Encode(OutputStream& os,
unsigned codepoint)
559 template <
typename OutputStream>
567 template <
typename InputStream>
568 static bool Decode(InputStream& is,
unsigned* codepoint)
573 return c <= 0x10FFFF;
576 template <
typename InputStream,
typename OutputStream>
577 static bool Validate(InputStream& is, OutputStream& os)
581 os.Put(c = is.Take());
582 return c <= 0x10FFFF;
587template <
typename CharType =
unsigned>
590 template <
typename InputByteStream>
594 CharType c =
Take(is);
595 return static_cast<uint32_t>(c) == 0x0000FEFFu ?
Take(is) : c;
598 template <
typename InputByteStream>
599 static CharType
Take(InputByteStream& is)
602 unsigned c =
static_cast<uint8_t>(is.Take());
603 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 8;
604 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 16;
605 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 24;
606 return static_cast<CharType
>(c);
609 template <
typename OutputByteStream>
613 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFFu));
614 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFEu));
615 os.Put(
static_cast<typename OutputByteStream::Ch
>(0x00u));
616 os.Put(
static_cast<typename OutputByteStream::Ch
>(0x00u));
619 template <
typename OutputByteStream>
620 static void Put(OutputByteStream& os, CharType c)
623 os.Put(
static_cast<typename OutputByteStream::Ch
>(c & 0xFFu));
624 os.Put(
static_cast<typename OutputByteStream::Ch
>((c >> 8) & 0xFFu));
625 os.Put(
static_cast<typename OutputByteStream::Ch
>((c >> 16) & 0xFFu));
626 os.Put(
static_cast<typename OutputByteStream::Ch
>((c >> 24) & 0xFFu));
631template <
typename CharType =
unsigned>
634 template <
typename InputByteStream>
638 CharType c =
Take(is);
639 return static_cast<uint32_t>(c) == 0x0000FEFFu ?
Take(is) : c;
642 template <
typename InputByteStream>
643 static CharType
Take(InputByteStream& is)
646 unsigned c =
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 24;
647 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 16;
648 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 8;
649 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take()));
650 return static_cast<CharType
>(c);
653 template <
typename OutputByteStream>
657 os.Put(
static_cast<typename OutputByteStream::Ch
>(0x00u));
658 os.Put(
static_cast<typename OutputByteStream::Ch
>(0x00u));
659 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFEu));
660 os.Put(
static_cast<typename OutputByteStream::Ch
>(0xFFu));
663 template <
typename OutputByteStream>
664 static void Put(OutputByteStream& os, CharType c)
667 os.Put(
static_cast<typename OutputByteStream::Ch
>((c >> 24) & 0xFFu));
668 os.Put(
static_cast<typename OutputByteStream::Ch
>((c >> 16) & 0xFFu));
669 os.Put(
static_cast<typename OutputByteStream::Ch
>((c >> 8) & 0xFFu));
670 os.Put(
static_cast<typename OutputByteStream::Ch
>(c & 0xFFu));
682template <
typename CharType =
char>
692 template <
typename OutputStream>
693 static void Encode(OutputStream& os,
unsigned codepoint)
696 os.Put(
static_cast<Ch>(codepoint & 0xFF));
699 template <
typename OutputStream>
706 template <
typename InputStream>
707 static bool Decode(InputStream& is,
unsigned* codepoint)
714 template <
typename InputStream,
typename OutputStream>
715 static bool Validate(InputStream& is, OutputStream& os)
718 os.Put(
static_cast<typename OutputStream::Ch
>(c));
722 template <
typename InputByteStream>
727 return static_cast<Ch>(c);
730 template <
typename InputByteStream>
734 return static_cast<Ch>(is.Take());
737 template <
typename OutputByteStream>
744 template <
typename OutputByteStream>
745 static void Put(OutputByteStream& os,
Ch c)
748 os.Put(
static_cast<typename OutputByteStream::Ch
>(c));
769template <
typename CharType>
779#define RAPIDJSON_ENCODINGS_FUNC(x) \
780 UTF8<Ch>::x, UTF16LE<Ch>::x, UTF16BE<Ch>::x, UTF32LE<Ch>::x, UTF32BE<Ch>::x
782 template <
typename OutputStream>
783 static RAPIDJSON_FORCEINLINE
void Encode(OutputStream& os,
unsigned codepoint)
785 typedef void (*EncodeFunc)(OutputStream&, unsigned);
787 (*f[os.GetType()])(os, codepoint);
790 template <
typename OutputStream>
791 static RAPIDJSON_FORCEINLINE
void EncodeUnsafe(OutputStream& os,
unsigned codepoint)
793 typedef void (*EncodeFunc)(OutputStream&, unsigned);
795 (*f[os.GetType()])(os, codepoint);
798 template <
typename InputStream>
799 static RAPIDJSON_FORCEINLINE
bool Decode(InputStream& is,
unsigned* codepoint)
801 typedef bool (*DecodeFunc)(InputStream&,
unsigned*);
803 return (*f[is.GetType()])(is, codepoint);
806 template <
typename InputStream,
typename OutputStream>
807 static RAPIDJSON_FORCEINLINE
bool Validate(InputStream& is, OutputStream& os)
809 typedef bool (*ValidateFunc)(InputStream&, OutputStream&);
811 return (*f[is.GetType()])(is, os);
814#undef RAPIDJSON_ENCODINGS_FUNC
821template <
typename SourceEncoding,
typename TargetEncoding>
826 template <
typename InputStream,
typename OutputStream>
827 static RAPIDJSON_FORCEINLINE
bool Transcode(InputStream& is, OutputStream& os)
830 if(!SourceEncoding::Decode(is, &codepoint))
832 TargetEncoding::Encode(os, codepoint);
836 template <
typename InputStream,
typename OutputStream>
840 if(!SourceEncoding::Decode(is, &codepoint))
842 TargetEncoding::EncodeUnsafe(os, codepoint);
847 template <
typename InputStream,
typename OutputStream>
848 static RAPIDJSON_FORCEINLINE
bool Validate(InputStream& is, OutputStream& os)
855template <
typename Stream>
859template <
typename Encoding>
862 template <
typename InputStream,
typename OutputStream>
863 static RAPIDJSON_FORCEINLINE
bool Transcode(InputStream& is, OutputStream& os)
870 template <
typename InputStream,
typename OutputStream>
878 template <
typename InputStream,
typename OutputStream>
879 static RAPIDJSON_FORCEINLINE
bool Validate(InputStream& is, OutputStream& os)
881 return Encoding::Validate(is, os);
887#if defined(__GNUC__) || (defined(_MSC_VER) && !defined(__clang__))
Concept for encoding of Unicode characters.
Concept for reading and writing characters.
#define RAPIDJSON_ENCODINGS_FUNC(x)
Definition encodings.h:779
UTFType
Runtime-specified UTF encoding type of a stream.
Definition encodings.h:757
@ kUTF32BE
UTF-32 big endian.
Definition encodings.h:762
@ kUTF16BE
UTF-16 big endian.
Definition encodings.h:760
@ kUTF8
UTF-8.
Definition encodings.h:758
@ kUTF32LE
UTF-32 little endian.
Definition encodings.h:761
@ kUTF16LE
UTF-16 little endian.
Definition encodings.h:759
void PutUnsafe(Stream &stream, typename Stream::Ch c)
Write character to a stream, presuming buffer is reserved.
Definition stream.h:96
#define RAPIDJSON_TRANS(mask)
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition rapidjson.h:451
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition rapidjson.h:124
common definitions and configuration
#define RAPIDJSON_STATIC_ASSERT(x)
(Internal) macro to check for conditions at compile-time
Definition rapidjson.h:500
unsigned short uint16_t
Definition stdint.h:125
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
ASCII encoding.
Definition encodings.h:684
CharType Ch
Definition encodings.h:685
static void Put(OutputByteStream &os, Ch c)
Definition encodings.h:745
static void PutBOM(OutputByteStream &os)
Definition encodings.h:738
static bool Validate(InputStream &is, OutputStream &os)
Definition encodings.h:715
static bool Decode(InputStream &is, unsigned *codepoint)
Definition encodings.h:707
@ supportUnicode
Definition encodings.h:689
static CharType TakeBOM(InputByteStream &is)
Definition encodings.h:723
static Ch Take(InputByteStream &is)
Definition encodings.h:731
static void Encode(OutputStream &os, unsigned codepoint)
Definition encodings.h:693
static void EncodeUnsafe(OutputStream &os, unsigned codepoint)
Definition encodings.h:700
Dynamically select encoding according to stream's runtime-specified UTF encoding type.
Definition encodings.h:771
static RAPIDJSON_FORCEINLINE void EncodeUnsafe(OutputStream &os, unsigned codepoint)
Definition encodings.h:791
CharType Ch
Definition encodings.h:772
@ supportUnicode
Definition encodings.h:776
static RAPIDJSON_FORCEINLINE bool Validate(InputStream &is, OutputStream &os)
Definition encodings.h:807
static RAPIDJSON_FORCEINLINE void Encode(OutputStream &os, unsigned codepoint)
Definition encodings.h:783
static RAPIDJSON_FORCEINLINE bool Decode(InputStream &is, unsigned *codepoint)
Definition encodings.h:799
static RAPIDJSON_FORCEINLINE bool Validate(InputStream &is, OutputStream &os)
Definition encodings.h:879
static RAPIDJSON_FORCEINLINE bool Transcode(InputStream &is, OutputStream &os)
Definition encodings.h:863
static RAPIDJSON_FORCEINLINE bool TranscodeUnsafe(InputStream &is, OutputStream &os)
Definition encodings.h:871
Encoding conversion.
Definition encodings.h:823
static RAPIDJSON_FORCEINLINE bool Transcode(InputStream &is, OutputStream &os)
Definition encodings.h:827
static RAPIDJSON_FORCEINLINE bool TranscodeUnsafe(InputStream &is, OutputStream &os)
Definition encodings.h:837
static RAPIDJSON_FORCEINLINE bool Validate(InputStream &is, OutputStream &os)
Validate one Unicode codepoint from an encoded stream.
Definition encodings.h:848
UTF-16 big endian encoding.
Definition encodings.h:494
static CharType TakeBOM(InputByteStream &is)
Definition encodings.h:496
static CharType Take(InputByteStream &is)
Definition encodings.h:504
static void Put(OutputByteStream &os, CharType c)
Definition encodings.h:521
static void PutBOM(OutputByteStream &os)
Definition encodings.h:513
UTF-16 encoding.
Definition encodings.h:367
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
static bool Decode(InputStream &is, unsigned *codepoint)
Definition encodings.h:415
static bool Validate(InputStream &is, OutputStream &os)
Definition encodings.h:436
CharType Ch
Definition encodings.h:368
@ supportUnicode
Definition encodings.h:373
static void Encode(OutputStream &os, unsigned codepoint)
Definition encodings.h:377
static void EncodeUnsafe(OutputStream &os, unsigned codepoint)
Definition encodings.h:396
UTF-16 little endian encoding.
Definition encodings.h:456
static CharType Take(InputByteStream &is)
Definition encodings.h:466
static void PutBOM(OutputByteStream &os)
Definition encodings.h:475
static CharType TakeBOM(InputByteStream &is)
Definition encodings.h:458
static void Put(OutputByteStream &os, CharType c)
Definition encodings.h:483
UTF-32 big endian encoding.
Definition encodings.h:633
static CharType TakeBOM(InputByteStream &is)
Definition encodings.h:635
static void PutBOM(OutputByteStream &os)
Definition encodings.h:654
static CharType Take(InputByteStream &is)
Definition encodings.h:643
static void Put(OutputByteStream &os, CharType c)
Definition encodings.h:664
UTF-32 encoding.
Definition encodings.h:542
static void Encode(OutputStream &os, unsigned codepoint)
Definition encodings.h:552
static bool Decode(InputStream &is, unsigned *codepoint)
Definition encodings.h:568
static bool Validate(InputStream &is, OutputStream &os)
Definition encodings.h:577
@ supportUnicode
Definition encodings.h:548
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=4)
CharType Ch
Definition encodings.h:543
static void EncodeUnsafe(OutputStream &os, unsigned codepoint)
Definition encodings.h:560
UTF-32 little endian enocoding.
Definition encodings.h:589
static void Put(OutputByteStream &os, CharType c)
Definition encodings.h:620
static CharType TakeBOM(InputByteStream &is)
Definition encodings.h:591
static void PutBOM(OutputByteStream &os)
Definition encodings.h:610
static CharType Take(InputByteStream &is)
Definition encodings.h:599
UTF-8 encoding.
Definition encodings.h:98
static bool Decode(InputStream &is, unsigned *codepoint)
Definition encodings.h:159
static CharType TakeBOM(InputByteStream &is)
Definition encodings.h:313
@ supportUnicode
Definition encodings.h:103
static Ch Take(InputByteStream &is)
Definition encodings.h:330
static void PutBOM(OutputByteStream &os)
Definition encodings.h:337
CharType Ch
Definition encodings.h:99
static bool Validate(InputStream &is, OutputStream &os)
Definition encodings.h:227
static void EncodeUnsafe(OutputStream &os, unsigned codepoint)
Definition encodings.h:133
static void Put(OutputByteStream &os, Ch c)
Definition encodings.h:346
static unsigned char GetRange(unsigned char c)
Definition encodings.h:283
static void Encode(OutputStream &os, unsigned codepoint)
Definition encodings.h:107