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
363  {
364  if (codepoint <= 0x7F)
365  *buffer++ = codepoint & 0xFF;
366  else if (codepoint <= 0x7FF) {
367  *buffer++ = 0xC0 | ((codepoint >> 6) & 0xFF);
368  *buffer++ = 0x80 | ((codepoint & 0x3F));
369  }
370  else if (codepoint <= 0xFFFF) {
371  *buffer++ = 0xE0 | ((codepoint >> 12) & 0xFF);
372  *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
373  *buffer++ = 0x80 | (codepoint & 0x3F);
374  }
375  else {
376  RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);
377  *buffer++ = 0xF0 | ((codepoint >> 18) & 0xFF);
378  *buffer++ = 0x80 | ((codepoint >> 12) & 0x3F);
379  *buffer++ = 0x80 | ((codepoint >> 6) & 0x3F);
380  *buffer++ = 0x80 | (codepoint & 0x3F);
381  }
382  return buffer;
383  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:105

References RAPIDJSON_ASSERT.


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