CLXVIII. Unicode Functions

简介

Unicode Support.

警告

This extension is still in development and it isn't available to public yet.

需求

ICU 3.4 or later is required.

安装

First you should download and install ICU:

例 1. install ICU on Unix

./configure --disable-threads --enable-extras --enable-icuio --enable-layout
make && make install

Then checkout latest PHP and configure it --with-icu-dir=<dir> option, where <dir> was the dir to where you installed ICU. You don't need to explicitly use this option if you install ICU to a standard location.

运行时配置

这些函数的行为受 php.ini 的影响。

表 1. Unicode Configuration Options

NameDefaultChangeableChangelog
unicode.fallback_encodingNULLPHP_INI_ALLAvailable since PHP 6.0.0.
unicode.from_error_mode"2"PHP_INI_ALLAvailable since PHP 6.0.0.
unicode.from_error_subst_char"3f"PHP_INI_ALLAvailable since PHP 6.0.0.
unicode.http_input_encodingNULLPHP_INI_ALLAvailable since PHP 6.0.0.
unicode.output_encodingNULLPHP_INI_ALLAvailable since PHP 6.0.0.
unicode.runtime_encodingNULLPHP_INI_ALLAvailable since PHP 6.0.0.
unicode.script_encodingNULLPHP_INI_ALLAvailable since PHP 6.0.0.
unicode.semanticsoffPHP_INI_PERDIRAvailable since PHP 6.0.0.
有关 PHP_INI_* 常量进一步的细节与定义参见附录 H

以下是配置选项的简要解释。

unicode.output_encoding string

Default encoding for output.

预定义常量

以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。

表 2.

constantvaluedescription
U_INVALID_STOP0stop at first invalid character
U_INVALID_SKIP1skip invalid characters
U_INVALID_SUBSTITUTE2replace invalid characters
U_INVALID_ESCAPE3escape invalid characters

目录
unicode_encode -- Set encoding of a unicode string
unicode_semantics -- Check whether unicode semantics is enabled

add a note add a note User Contributed Notes
Tomas Kuliavas
24-May-2007 06:32
unicode.semantics is only PHP_INI_SYSTEM

See discussion about it at http://devzone.zend.com/node/view/id/1510#Heading5
Hugo Dworak (post at o2 dot pl)
23-Nov-2005 03:04
If you are really interested in PHP 6 and its Unicode support you should read:
http://www.zend.com/zend/week/php-unicode-design.txt
(and in general http://www.zend.com/zend/week/)
plus cvs/php6/README.UNICODE and cvs/php6/README.UNICODE-UPGRADES

After you compile PHP 6, make sure that you have enabled unicode_semantics = on in php.ini (an old PHP 5 configuration file will not do as it does not provide those new Unicode-related options).