rapidjson::UTF8< CharType > Struct Template Reference

UTF-8 encoding. More...

#include <rapidjson.h>

+ Inheritance diagram for rapidjson::UTF8< CharType >:

Public Types

typedef CharType Ch
 

Static Public Member Functions

static ChEncode (Ch *buffer, unsigned codepoint)
 

Detailed Description

template<typename CharType = char>
struct rapidjson::UTF8< CharType >

UTF-8 encoding.

http://en.wikipedia.org/wiki/UTF-8

Template Parameters
CharTypeType for storing 8-bit UTF-8 data. Default is char.

Member Typedef Documentation

◆ Ch

template<typename CharType = char>
typedef CharType rapidjson::UTF8< CharType >::Ch

Member Function Documentation

◆ Encode()

template<typename CharType = char>
static Ch* rapidjson::UTF8< CharType >::Encode ( Ch buffer,
unsigned  codepoint 
)
inlinestatic
338  {
339  if (codepoint <= 0x7F)
340  *buffer++ = codepoint & 0xFF;
341  else if (codepoint <= 0x7FF) {
342  *buffer++ = 0xC0 | ((codepoint >> 6) & 0xFF);
343  *buffer++ = 0x80 | ((codepoint & 0x3F));
344  }
345  else if (codepoint <= 0xFFFF) {
346  *buffer++ = 0xE0 | ((codepoint >> 12) & 0xFF);
347  *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
348  *buffer++ = 0x80 | (codepoint & 0x3F);
349  }
350  else {
351  RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);
352  *buffer++ = 0xF0 | ((codepoint >> 18) & 0xFF);
353  *buffer++ = 0x80 | ((codepoint >> 12) & 0x3F);
354  *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
355  *buffer++ = 0x80 | (codepoint & 0x3F);
356  }
357  return buffer;
358  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:80

References RAPIDJSON_ASSERT.


The documentation for this struct was generated from the following file: