Samchon Framework for CPP  1.0.0
samchon::library::Charset Class Reference

A utility class supporting conversion between multiple character-sets. More...

#include <Charset.hpp>

Static Public Member Functions

static auto toMultibyte (const std::string &source) -> std::string
 Convert utf-8 to multibyte. More...
 
static auto toMultibyte (const std::wstring &source) -> std::string
 Convert unicode to multibyte. More...
 
static auto toUTF8 (const std::string &source) -> std::string
 Convert multibyte to utf-8. More...
 
static auto toUTF8 (const std::wstring &source) -> std::string
 Convert unicode to utf-8. More...
 
static auto toUnicode (const std::string &source, int charset) -> std::wstring
 Convert multibyte or utf-8 to unicode. More...
 

Detailed Description

A utility class supporting conversion between multiple character-sets.

Charset class, it's easier to think iconv in linux

Supported character-sets

  • Multibyte (ANSI)
  • UTF-8
  • Unicode (UTF-16)
library_string.png
Warning
In some system, std::wstring is not for utf-8 but for unicode (utf-16).
See also
samchon::library
Author
Jeongho Nam http://samchon.org

Definition at line 35 of file Charset.hpp.

Member Function Documentation

static auto samchon::library::Charset::toMultibyte ( const std::string &  source) -> std::string
inlinestatic

Convert utf-8 to multibyte.

Converts utf-8 string to multibyte string.

If the utf-8 string has header int the front, it will be erased.

Warning
If utf-8 header is not at the front of string, it can't be erased and may cause breakage on letters
Parameters
strA utf-8 string would be converted to multibyte
Returns
A multibyte string

Definition at line 56 of file Charset.hpp.

References toUnicode().

Here is the call graph for this function:

static auto samchon::library::Charset::toMultibyte ( const std::wstring &  source) -> std::string
inlinestatic

Convert unicode to multibyte.

Converts unicode string to multibyte string
If the unicode string has header in the front, it will be erased

Warning
If unicode header is not at the front of string, it can't be erased and may cause breakage on letters
Parameters
strA unicode string to be converted
Returns
A multibyte string

Definition at line 76 of file Charset.hpp.

static auto samchon::library::Charset::toUTF8 ( const std::string &  source) -> std::string
inlinestatic

Convert multibyte to utf-8.

Converts multibyte string to utf-8 string
If the inputted string is not multibyte, then may cause breakage on letters

Warning
Converted utf-8 string does not contain the header
Parameters
strA multibyte string would be converted
Returns
A utf-8 string

Definition at line 122 of file Charset.hpp.

References toUnicode().

Here is the call graph for this function:

static auto samchon::library::Charset::toUTF8 ( const std::wstring &  source) -> std::string
inlinestatic

Convert unicode to utf-8.

Converts unicode string to utf-8 string
Generated utf-8 string follows unicode string wheter to have header or not

  • If the unicode string has header on first, utf-8 will also have the header, too
  • If not, generated utf-8 string doesn't have the header, either
Parameters
strA unicode string would be converted
Returns
A utf-8 string

Definition at line 145 of file Charset.hpp.

static auto samchon::library::Charset::toUnicode ( const std::string &  source,
int  charset 
) -> std::wstring
inlinestatic

Convert multibyte or utf-8 to unicode.

Parameters
strA multibyte or utf-8 string would be converted
Designatestr is multibyte or utf-8 string
Returns
A unicode string

Definition at line 166 of file Charset.hpp.

Referenced by toMultibyte(), and toUTF8().

Here is the caller graph for this function:


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