Loading...
Searching...
No Matches
opencc::UTF8Util Class Reference
OpenCC C++ Comprehensive API

UTF8 std::string utilities. More...

`#include <src/UTF8Util.hpp>`

## Static Public Member Functions

static void | SkipUtf8Bom (FILE *fp)
| Detect UTF8 BOM and skip it.
static size_t | NextCharLengthNoException (const char *str)
| Returns the length in byte for the next UTF8 character.
static size_t | NextCharLength (const char *str)
| Returns the length in byte for the next UTF8 character.
static size_t | PrevCharLength (const char *str)
| Returns the length in byte for the previous UTF8 character.
static const char * | NextChar (const char *str)
| Returns the char* pointer over the next UTF8 character.
static const char * | PrevChar (const char *str)
| Move the char* pointer before the previous UTF8 character.
static size_t | IdeographicDescriptionOperatorArity (uint32_t codePoint)
static size_t | NextIdeographicDescriptionSequenceLength (const char *str, size_t len)
static bool | IsIncompleteIdeographicDescriptionSequencePrefix (const char *str, size_t len)
static bool | IsVariationSelector (uint32_t codePoint)
static bool | ContainsVariationSelector (const char *str, size_t len)
static size_t | Length (const char *str)
| Returns the UTF8 length of a null-terminated string.
static const char * | FindNextInline (const char *str, const char ch)
| Finds a character in the same line.
static bool | IsLineEndingOrFileEnding (const char ch)
| Returns true if the character is a line ending or end of file.
static std::string | FromSubstr (const char *str, size_t length)
| Copies a substring with given length to a new string.
static bool | NotShorterThan (const char *str, size_t byteLength)
| Returns true if the given std::string is longer or as long as the given length.
static std::string | TruncateUTF8 (const char *str, size_t maxByteLength)
| Truncates a std::string with a maximal length in byte.
static void | ReplaceAll (std::string &str, const char *from, const char *to)
| Replaces all patterns in a std::string in place.
static std::string | Join (const std::vector< std::string > &strings, const std::string &separator)
| Joins a std::string vector in to a std::string with a separator.
static std::string | Join (const std::vector< std::string > &strings)
| Joins a std::string vector in to a std::string.
static void | GetByteMap (const char *str, const size_t utf8Length, std::vector< size_t > *byteMap)
static std::string | GetPlatformString (const std::string &str)

## Detailed Description

UTF8 std::string utilities.

## Member Function Documentation

## FindNextInline()

const char * opencc::UTF8Util::FindNextInline | ( | const char * | str,
|  | const char | ch )

inline static

Finds a character in the same line.

Parameters

  str | The text to be searched in.
  ch | The character to find.

Returns
  The pointer that points to the found chacter in str or EOL/EOF.

## Length()

size_t opencc::UTF8Util::Length | ( | const char * | str | ) |

inline static

Returns the UTF8 length of a null-terminated string.

Throws InvalidUTF8 for invalid or truncated byte sequences. The truncated-sequence check reads only up to the null terminator, so it does not read out of bounds (issue #799 fix).

## NextCharLengthNoException()

size_t opencc::UTF8Util::NextCharLengthNoException | ( | const char * | str | ) |

inline static

Returns the length in byte for the next UTF8 character.

On error returns 0.

## TruncateUTF8()

std::string opencc::UTF8Util::TruncateUTF8 | ( | const char * | str,
|  | size_t | maxByteLength )

inline static

Truncates a std::string with a maximal length in byte.

No UTF8 character will be broken.

The documentation for this class was generated from the following files:

- UTF8Util.hpp
- UTF8Util.cpp