UTF-16 big endian encoding.
More...
#include <encodings.h>
|
template<typename InputByteStream > |
static CharType | TakeBOM (InputByteStream &is) |
|
template<typename InputByteStream > |
static CharType | Take (InputByteStream &is) |
|
template<typename OutputByteStream > |
static void | PutBOM (OutputByteStream &os) |
|
template<typename OutputByteStream > |
static void | Put (OutputByteStream &os, CharType c) |
|
template<typename OutputStream > |
static void | Encode (OutputStream &os, unsigned codepoint) |
|
template<typename OutputStream > |
static void | EncodeUnsafe (OutputStream &os, unsigned codepoint) |
|
template<typename InputStream > |
static bool | Decode (InputStream &is, unsigned *codepoint) |
|
template<typename InputStream , typename OutputStream > |
static bool | Validate (InputStream &is, OutputStream &os) |
|
template<typename CharType = wchar_t>
struct UTF16BE< CharType >
UTF-16 big endian encoding.
Definition at line 375 of file encodings.h.
◆ Ch
◆ anonymous enum
◆ Decode()
static bool Decode |
( |
InputStream & |
is, |
|
|
unsigned * |
codepoint |
|
) |
| |
|
inlinestaticinherited |
Definition at line 307 of file encodings.h.
309 typename InputStream::Ch c = is.Take();
310 if (c < 0xD800 || c > 0xDFFF) {
311 *codepoint =
static_cast<unsigned>(c);
314 else if (c <= 0xDBFF) {
315 *codepoint = (
static_cast<unsigned>(c) & 0x3FF) << 10;
317 *codepoint |= (
static_cast<unsigned>(c) & 0x3FF);
318 *codepoint += 0x10000;
319 return c >= 0xDC00 && c <= 0xDFFF;
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
◆ Encode()
static void Encode |
( |
OutputStream & |
os, |
|
|
unsigned |
codepoint |
|
) |
| |
|
inlinestaticinherited |
Definition at line 276 of file encodings.h.
278 if (codepoint <= 0xFFFF) {
280 os.Put(static_cast<typename OutputStream::Ch>(codepoint));
284 unsigned v = codepoint - 0x10000;
285 os.Put(static_cast<typename OutputStream::Ch>((v >> 10) | 0xD800));
286 os.Put(static_cast<typename OutputStream::Ch>((v & 0x3FF) | 0xDC00));
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
#define RAPIDJSON_ASSERT(x)
Assertion.
◆ EncodeUnsafe()
static void EncodeUnsafe |
( |
OutputStream & |
os, |
|
|
unsigned |
codepoint |
|
) |
| |
|
inlinestaticinherited |
Definition at line 292 of file encodings.h.
294 if (codepoint <= 0xFFFF) {
296 PutUnsafe(os, static_cast<typename OutputStream::Ch>(codepoint));
300 unsigned v = codepoint - 0x10000;
301 PutUnsafe(os, static_cast<typename OutputStream::Ch>((v >> 10) | 0xD800));
302 PutUnsafe(os, static_cast<typename OutputStream::Ch>((v & 0x3FF) | 0xDC00));
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
void PutUnsafe(Stream &stream, typename Stream::Ch c)
Write character to a stream, presuming buffer is reserved.
#define RAPIDJSON_ASSERT(x)
Assertion.
◆ Put()
static void Put |
( |
OutputByteStream & |
os, |
|
|
CharType |
c |
|
) |
| |
|
inlinestatic |
Definition at line 399 of file encodings.h.
401 os.Put(static_cast<typename OutputByteStream::Ch>((static_cast<unsigned>(c) >> 8) & 0xFFu));
402 os.Put(static_cast<typename OutputByteStream::Ch>(static_cast<unsigned>(c) & 0xFFu));
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
◆ PutBOM()
static void PutBOM |
( |
OutputByteStream & |
os | ) |
|
|
inlinestatic |
Definition at line 392 of file encodings.h.
394 os.Put(static_cast<typename OutputByteStream::Ch>(0xFEu));
395 os.Put(static_cast<typename OutputByteStream::Ch>(0xFFu));
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
◆ RAPIDJSON_STATIC_ASSERT()
RAPIDJSON_STATIC_ASSERT |
( |
sizeof(Ch) >= |
2 | ) |
|
|
inherited |
◆ Take()
static CharType Take |
( |
InputByteStream & |
is | ) |
|
|
inlinestatic |
Definition at line 384 of file encodings.h.
386 unsigned c =
static_cast<unsigned>(
static_cast<uint8_t>(is.Take())) << 8;
387 c |=
static_cast<unsigned>(
static_cast<uint8_t>(is.Take()));
388 return static_cast<CharType
>(c);
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
◆ TakeBOM()
static CharType TakeBOM |
( |
InputByteStream & |
is | ) |
|
|
inlinestatic |
Definition at line 377 of file encodings.h.
379 CharType c =
Take(is);
380 return static_cast<uint16_t>(c) == 0xFEFFu ?
Take(is) : c;
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
static CharType Take(InputByteStream &is)
◆ Validate()
static bool Validate |
( |
InputStream & |
is, |
|
|
OutputStream & |
os |
|
) |
| |
|
inlinestaticinherited |
Definition at line 325 of file encodings.h.
328 typename InputStream::Ch c;
329 os.Put(static_cast<typename OutputStream::Ch>(c = is.Take()));
330 if (c < 0xD800 || c > 0xDFFF)
332 else if (c <= 0xDBFF) {
333 os.Put(c = is.Take());
334 return c >= 0xDC00 && c <= 0xDFFF;
RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >=2)
The documentation for this struct was generated from the following file: