class Encoding (View source)

Encoding conversion helper class

Constants

ENGINE_NONE

None encoding conversion engine

ENGINE_ICONV

iconv 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 $srcCharset, string $destCharset, 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

static void initEngine()

Initializes encoding engine detecting available backends.

Return Value

void

static void setEngine(int $engine)

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

Parameters

int $engine

Engine encoding

Return Value

void

static bool isSupported()

Checks whether there is any charset conversion supported

Return Value

bool

static string convertString(string $srcCharset, string $destCharset, string $what)

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

Parameters

string $srcCharset

source charset

string $destCharset

target charset

string $what

what to convert

Return Value

string

converted text

static bool canConvertKanji()

Detects whether Kanji encoding is available

Return Value

bool

static string getKanjiEncodings()

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

Return Value

string

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

static void kanjiChangeOrder()

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

Return Value

void

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

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

static string kanjiEncodingForm()

Defines radio form fields to switch between encoding modes

Return Value

string

HTML code for the radio controls

static array listEncodings()

Lists available encodings.

Return Value

array