# Unicode.hpp

This File On Github
Ask A Question

API: latest
module: oatpp
#include "oatpp/encoding/Unicode.hpp"

# Unicode

Helper class for processing unicode characters.

namespace oatpp { namespace encoding { 
  class Unicode {}
}}

# Methods

Return Type Name Summary
v_buff_size getUtf8CharSequenceLength Get length in bytes of UTF-8 character by its first byte.
v_buff_size getUtf8CharSequenceLengthForCode Get length in bytes of UTF-8 character by its code.
v_int32 encodeUtf8Char Get code of UTF-8 character.
v_buff_size decodeUtf8Char Write UTF-8 character to buffer.
void codeToUtf16SurrogatePair Get corresponding UTF-16 surrogate pair for symbol code.
v_int32 utf16SurrogatePairToCode Get symbol code of corresponding UTF-16 surrogate pair.

# Unicode::getUtf8CharSequenceLength

Get length in bytes of UTF-8 character by its first byte.

  • @param firstByte - first byte of UTF-8 character.
  • @return - length in bytes of UTF-8 character.

static v_buff_size getUtf8CharSequenceLength(v_char8 firstByte)

# Unicode::getUtf8CharSequenceLengthForCode

Get length in bytes of UTF-8 character by its code.

  • @param code - code of UTF-8 character.
  • @return - length in bytes of UTF-8 character.

static v_buff_size getUtf8CharSequenceLengthForCode(v_uint32 code)

# Unicode::encodeUtf8Char

Get code of UTF-8 character.

  • @param sequence - pointer to first byte of UTF-8 character.
  • @param length - out parameter. Length in bytes of UTF-8 character.
  • @return - code of UTF-8 character.

static v_int32 encodeUtf8Char(const char* sequence, v_buff_size& length)

# Unicode::decodeUtf8Char

Write UTF-8 character to buffer.

  • @param code - UTF-8 character code.
  • @param buffer - pointer to write UTF-8 character to.
  • @return - length in bytes of UTF-8 character.

static v_buff_size decodeUtf8Char(v_int32 code, p_char8 buffer)

# Unicode::codeToUtf16SurrogatePair

Get corresponding UTF-16 surrogate pair for symbol code.

  • @param code - symbol code.
  • @param high - out parameter. High surrogate.
  • @param low - out parameter. Low surrogate.

static void codeToUtf16SurrogatePair(v_int32 code, v_int16& high, v_int16& low)

# Unicode::utf16SurrogatePairToCode

Get symbol code of corresponding UTF-16 surrogate pair.

  • @param high - High surrogate.
  • @param low - Low surrogate.
  • @return - symbol code.

static v_int32 utf16SurrogatePairToCode(v_int16 high, v_int16 low)