Lumino
ln::TextEncoding Class Referenceabstract

文字エンコーディングを表します。 More...

#include <Encoding.hpp>

Inheritance diagram for ln::TextEncoding:
ln::RefObject

Public Member Functions

String decode (const byte_t *bytes, int length, int *outUsedDefaultCharCount=nullptr)
 エンコード済みバイトシーケンスを String へ変換します。
 
std::vector< byte_t > encode (const String &str, int *outUsedDefaultCharCount=nullptr)
 String をバイトシーケンスへ変換します。
 
std::vector< byte_t > encode (const Char *str, int length, int *outUsedDefaultCharCount=nullptr)
 Char 配列をバイトシーケンスへ変換します。
 
virtual const Stringname () const =0
 このエンコーディングの名前を取得します。 More...
 
virtual int minByteCount () const =0
 1 文字の最小バイト数を取得します。
 
virtual int maxByteCount () const =0
 1 文字の最大バイト数を取得します。
 
virtual TextDecodercreateDecoder ()=0
 バイトシーケンスを内部文字列へ変換するデコーダを作成します。 More...
 
virtual TextEncodercreateEncoder ()=0
 内部文字列をバイトシーケンスへ変換するエンコーダを作成する More...
 
virtual byte_t * preamble () const =0
 このエンコードを識別するための BOM (Byte order mark) を取得します。 More...
 
virtual int getCharacterCount (const void *buffer, size_t bufferSize) const =0
 指定されたバッファをこのエンコーディングで表現した際の文字数を取得します。 More...
 
virtual int getLeadExtraLength (const void *buffer, size_t bufferSize) const =0
 指定されたバッファの先頭がマルチバイトコードやサロゲートペアの先行文字である場合、追加で読むべき文字列長さを返します。 More...
 
size_t checkPreamble (const void *buffer, size_t bufferSize) const
 指定されたバッファの先頭バイト列が、BOM と一致するかを確認します。 More...
 
void setFallbackReplacementChar (uint32_t ch)
 デコードまたはエンコード先にマッピングできない文字が見つかった時に置換する文字を設定します。
 
uint32_t fallbackReplacementChar () const
 デコードまたはエンコード先にマッピングできない文字が見つかった時に置換する文字を取得します。
 

Static Public Member Functions

static const Ref< TextEncoding > & systemMultiByteEncoding ()
 環境依存のマルチバイト文字コードのエンコーディングを取得します。 More...
 
static const Ref< TextEncoding > & wideCharEncoding ()
 環境依存のワイド文字のエンコーディングを取得します。 More...
 
static const Ref< TextEncoding > & tcharEncoding ()
 互換性のために残されています
 
static const Ref< TextEncoding > & utf8Encoding ()
 UTF-8 エンコーディングを取得します。 More...
 
static const Ref< TextEncoding > & utf16Encoding ()
 UTF-16 エンコーディングを取得します。 More...
 
static const Ref< TextEncoding > & utf32Encoding ()
 UTF-32 エンコーディングを取得します。 More...
 
static const Ref< TextEncoding > & getEncoding (EncodingType type)
 エンコーディングの種類を指定して TextEncoding オブジェクトを取得します。
 
template<typename TChar >
static const Ref< TextEncoding > & getEncodingTemplate ()
 テンプレート引数によって TextEncoding オブジェクトを取得します。
 
static size_t getConversionRequiredByteCount (TextEncoding *from, TextEncoding *to, size_t fromByteCount)
 エンコーディングを from から to へ fromByteCount バイト分だけ変換する際に必要な、変換先バッファの最大バイト数を取得します。
 
static const Ref< TextEncoding > & detectEncodingSimple (const char *str, int length, bool strict)
 バイトシーケンスがどのようなエンコーディングで表されているかを簡易的に判別します。 More...
 

Additional Inherited Members

- Protected Member Functions inherited from ln::RefObject
virtual void finalize ()
 参照がなくなり、オブジェクトが削除されようとしているときに呼び出されます。実装コードでは仮想関数を呼び出すことができます。主にデストラクタの制限を回避するために使用します。
 

Detailed Description

文字エンコーディングを表します。

Member Function Documentation

◆ checkPreamble()

size_t ln::TextEncoding::checkPreamble ( const void *  buffer,
size_t  bufferSize 
) const

指定されたバッファの先頭バイト列が、BOM と一致するかを確認します。

Returns
一致した場合は BOM のバイト数を返します。そうでなければ 0 を返します。

◆ createDecoder()

virtual TextDecoder* ln::TextEncoding::createDecoder ( )
pure virtual

バイトシーケンスを内部文字列へ変換するデコーダを作成します。

作成したオブジェクトは、使い終えたら削除する必要があります。

◆ createEncoder()

virtual TextEncoder* ln::TextEncoding::createEncoder ( )
pure virtual

内部文字列をバイトシーケンスへ変換するエンコーダを作成する

作成したオブジェクトは、使い終えたら削除する必要があります。

◆ detectEncodingSimple()

static const Ref<TextEncoding>& ln::TextEncoding::detectEncodingSimple ( const char *  str,
int  length,
bool  strict 
)
static

バイトシーケンスがどのようなエンコーディングで表されているかを簡易的に判別します。

判別できるエンコーディングは ASCII と UTF-8 です。それ以外の場合は systemMultiByteEncoding() で返されるエンコーディングとみなされます。

◆ getCharacterCount()

virtual int ln::TextEncoding::getCharacterCount ( const void *  buffer,
size_t  bufferSize 
) const
pure virtual

指定されたバッファをこのエンコーディングで表現した際の文字数を取得します。

Returns
文字数。マルチバイトコードやサロゲートペアを考慮した文字数です。

◆ getLeadExtraLength()

virtual int ln::TextEncoding::getLeadExtraLength ( const void *  buffer,
size_t  bufferSize 
) const
pure virtual

指定されたバッファの先頭がマルチバイトコードやサロゲートペアの先行文字である場合、追加で読むべき文字列長さを返します。

Returns
追加で読むべき文字列長さ。先行文字ではない場合は 0。

◆ name()

virtual const String& ln::TextEncoding::name ( ) const
pure virtual

このエンコーディングの名前を取得します。

名前は IANA 文字セット名です。(http://www.iana.org/assignments/character-sets/character-sets.xhtml) Windows コードページによるエンコーディングを使用している場合、"cp437" のようなエイリアス名になることがあります。

◆ preamble()

virtual byte_t* ln::TextEncoding::preamble ( ) const
pure virtual

このエンコードを識別するための BOM (Byte order mark) を取得します。

Returns
0 で終わるバイト列。BOM を持たないエンコードの場合は nullptr

◆ systemMultiByteEncoding()

static const Ref<TextEncoding>& ln::TextEncoding::systemMultiByteEncoding ( )
static

環境依存のマルチバイト文字コードのエンコーディングを取得します。

Windows 環境では CP_THREAD_ACP が示すコードページエンコーディングです。それ以外の環境では UTF-8 となります。

◆ utf16Encoding()

static const Ref<TextEncoding>& ln::TextEncoding::utf16Encoding ( )
static

UTF-16 エンコーディングを取得します。

このエンコーディングは ln::String や ln::Char のエンコーディングです。 エンディアンはプログラムの動作環境に依存します。 BOM (Byte order mark) は付きません。

◆ utf32Encoding()

static const Ref<TextEncoding>& ln::TextEncoding::utf32Encoding ( )
static

UTF-32 エンコーディングを取得します。

エンディアンはプログラムの動作環境に依存します。 BOM (Byte order mark) は付きません。

◆ utf8Encoding()

static const Ref<TextEncoding>& ln::TextEncoding::utf8Encoding ( )
static

UTF-8 エンコーディングを取得します。

BOM (Byte order mark) は付きません。

◆ wideCharEncoding()

static const Ref<TextEncoding>& ln::TextEncoding::wideCharEncoding ( )
static

環境依存のワイド文字のエンコーディングを取得します。

wchar_t のサイズによって UTF-16 または UTF-32 となります。


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