class Encoding

Encoding conversion helper class

Constants

ENGINE_NONE

None encoding conversion engine

ENGINE_ICONV

iconv encoding conversion engine

ENGINE_RECODE

recode encoding conversion engine

ENGINE_MB

mbstring encoding conversion engine

Methods

static void
initEngine()

Initializes encoding engine detecting available backends.

static void
setEngine(int $engine)

Setter for engine. Use with caution, mostly useful for testing.

static bool
isSupported()

Checks whether there is any charset conversion supported

static string
convertString(string $src_charset, string $dest_charset, string $what)

Converts encoding of text according to parameters with detected conversion function.

static bool
canConvertKanji()

Detects whether Kanji encoding is available

static string
getKanjiEncodings()

Setter for Kanji encodings. Use with caution, mostly useful for testing.

static void
setKanjiEncodings(string $value)

Setter for Kanji encodings. Use with caution, mostly useful for testing.

static void
kanjiChangeOrder()

Reverses SJIS & EUC-JP position in the encoding codes list

static string
kanjiStrConv(string $str, string $enc, string $kana)

Kanji string encoding convert

static string
kanjiFileConv(string $file, string $enc, string $kana)

Kanji file encoding convert

static string
kanjiEncodingForm()

Defines radio form fields to switch between encoding modes

static array
listEncodings()

Lists available encodings.

Details

at line 114
static void initEngine()

Initializes encoding engine detecting available backends.

Return Value

void

at line 150
static void setEngine(int $engine)

Setter for engine. Use with caution, mostly useful for testing.

Parameters

int $engine Engine encoding

Return Value

void

at line 160
static bool isSupported()

Checks whether there is any charset conversion supported

Return Value

bool

at line 180
static string convertString(string $src_charset, string $dest_charset, string $what)

Converts encoding of text according to parameters with detected conversion function.

Parameters

string $src_charset source charset
string $dest_charset target charset
string $what what to convert

Return Value

string converted text

at line 220
static bool canConvertKanji()

Detects whether Kanji encoding is available

Return Value

bool

at line 230
static string getKanjiEncodings()

Setter for Kanji encodings. Use with caution, mostly useful for testing.

Return Value

string

at line 242
static void setKanjiEncodings(string $value)

Setter for Kanji encodings. Use with caution, mostly useful for testing.

Parameters

string $value Kanji encodings list

Return Value

void

at line 252
static void kanjiChangeOrder()

Reverses SJIS & EUC-JP position in the encoding codes list

Return Value

void

at line 271
static string kanjiStrConv(string $str, string $enc, string $kana)

Kanji string encoding convert

Parameters

string $str the string to convert
string $enc the destination encoding code
string $kana set 'kana' convert to JIS-X208-kana

Return Value

string the converted string

at line 304
static string kanjiFileConv(string $file, string $enc, string $kana)

Kanji file encoding convert

Parameters

string $file the name of the file to convert
string $enc the destination encoding code
string $kana set 'kana' convert to JIS-X208-kana

Return Value

string the name of the converted file

at line 331
static string kanjiEncodingForm()

Defines radio form fields to switch between encoding modes

Return Value

string HTML code for the radio controls

at line 342
static array listEncodings()

Lists available encodings.

Return Value

array