PHP 手冊
上一頁 |  | 下一頁

# XLII.iconv Functions

# 介紹

This module contains an interface to iconv character set conversion facility. With this module, you can turn a string represented by a local character set into the one represented by another character set, which may be the Unicode charcter set. Supported character sets depend on the iconv implementation of your system. Note that the iconv function on some systems may not work as you expect. In such case, it'd be a good idea to install the GNU libiconv library. It will most likely end up with more consistent results.

Since PHP 5.0.0, this extension comes with various utility functions that help you to write multilingual scripts. Let's have a look at the following sections to explore the new features.

# 需求

You will need nothing if the system you are using is one of the recent POSIX-compliant systems because standard C libraries that are supplied in them must provide iconv facility. Otherwise, you have to get the libiconv library installed in your system.

# 安裝

To use functions provided by this module, the PHP binary must be built with the following configure line: --with-iconv[=DIR].

> Note to Windows® Users: In order to enable this module on a Windows® environment, you need to put a DLL file named iconv.dll or iconv-1.3.dll (prior to 4.2.1) which is bundled with the PHP/Win32 binary package into a directory specified by the PATH environment variable or one of the system directories of your Windows® installation.

# 執行時期組態

`php.ini`中的設定會影響這些函數的行為。

表格 1.Iconv configuration options

Name | Default | Changeable
--- | --- | ---
iconv.input_encoding | ICONV_INPUT_ENCODING | PHP_INI_ALL
iconv.output_encoding | ICONV_OUTPUT_ENCODING | PHP_INI_ALL
iconv.internal_encoding | ICONV_INTERNAL_ENCODING | PHP_INI_ALL

For further details and definition of the PHP_INI_* constants see ini_set().

# 資源類型

這個延伸沒有定義任何資源。

# 預先定義常數

Since PHP 4.3.0 it is possible to identify at runtime which iconv implementation is adopted by this extension.

表格 2.iconv constants

Name | Type | Description
--- | --- | ---
ICONV_IMPL | string | The implementation name
ICONV_VERSION | string | The implementation version

> 備注: Writing implementation-dependent scripts with these constants is strongly discouraged.

Since PHP 5.0.0, the following constants are also available:

表格 3.iconv constants available since PHP 5.0.0

Name | Type | Description
--- | --- | ---
ICONV_MIME_DECODE_STRICT | integer | A bitmask used for iconv_mime_decode()
ICONV_MIME_DECODE_CONTINUE_ON_ERROR | integer | A bitmask used for iconv_mime_decode()

# 參考

See also GNU Recode functions.

上一頁 | 最開頭 | 下一頁
hw_api->userlist | 上一層 | iconv_get_encoding