LXII. 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 character 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.
This module is part of PHP as of PHP 5 thus iconv.dll and php_iconv.dll is not needed anymore.
运行时配置
这些函数的行为受 php.ini 的影响。
表113.Iconv configuration options
| Name | Default | Changeable | Changelog |
|---|---|---|---|
| iconv.input_encoding | "ISO-8859-1" | PHP_INI_ALL | Available since PHP 4.0.5. |
| iconv.output_encoding | "ISO-8859-1" | PHP_INI_ALL | Available since PHP 4.0.5. |
| iconv.internal_encoding | "ISO-8859-1" | PHP_INI_ALL | Available since PHP 4.0.5. |
有关 PHP_INI_* 常量进一步的细节与定义参见附录H, php.ini 配置选项。
Some systems (like IBM AIX) use "ISO8859-1" instead of "ISO-8859-1" so this value has to be used in configuration options and function parameters.
注意: Configuration option iconv.input_encoding is currently not used for anything.
资源类型
本扩展模块未定义任何资源类型。
预定义常量
Since PHP 4.3.0 it is possible to identify at runtime which iconv implementation is adopted by this extension.
注意: Writing implementation-dependent scripts with these constants is strongly discouraged.
Since PHP 5.0.0, the following constants are also available:
表115.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.
目录
- iconv_get_encoding Retrieve internal configuration variables of iconv extension
- iconv_mime_decode_headers Decodes multiple MIME header fields at once
- iconv_mime_decode Decodes a MIME header field
- iconv_mime_encode Composes a MIME header field
- iconv_set_encoding Set current setting for character encoding conversion
- iconv_strlen Returns the character count of string
- iconv_strpos Finds position of first occurrence of a needle within a haystack
- iconv_strrpos Finds the last occurrence of a needle within a haystack
- iconv_substr Cut out part of a string
- iconv Convert string to requested character encoding
- ob_iconv_handler Convert character encoding as output buffer handler
add a note
User Contributed Notesiconv Functions

icap_store_event