📄 readme_php3-i18n-ja
字号:
Encoding such as ISO-2022-** and HZ encoding which uses escape sequences can not be used as internal encoding. If used, they result in following errors: - parser pukes funky error - magic_quotes_*** breaks encoding (SJIS may have similar problem) - string manipulation and regex will malfunctiono i18n.script_encoding - script encoding i18n.script_encoding = auto|EUC-JP|SJIS|JIS|UTF-8 auto: automatic EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 The default is auto. The script's encoding is converted to i18n.internal_encoding before entering the script parser. Be aware that auto detection may fail under some conditions. For best auto detection, add multibyte charactor at begining of script.o i18n.http_input - handling of http input (GET/POST/COOKIE) i18n.http_input = pass|auto auto: auto conversion pass: no conversion The default is auto. If set to pass, no conversion will take place. If set to auto, it will automatically detect the encoding. If detection is successful, it will convert to the proper internal encoding. If not, it will assume the input as defined in i18n.http_input_default.o i18n.http_input_default - default http input encoding i18n.http_input_default = pass|EUC-JP|SJIS|JIS|UTF-8 pass: no conversion EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 The default is pass. This option is only effective as long as i18n.http_input is set to auto. If the auto detection fails, this encoding is used as an assumption to convert the http input to the internal encoding. If set to pass, no conversion will take place.o sample settings 1) For most flexibility, we recommend using following example. i18n.http_output = SJIS i18n.internal_encoding = EUC-JP i18n.script_encoding = auto i18n.http_input = auto i18n.http_input_default = SJIS 2) To avoid unexpected encoding problems, try these: i18n.http_output = pass i18n.internal_encoding = EUC-JP i18n.script_encoding = pass i18n.http_input = pass i18n.http_input_default = pass========================================== PHP functions==========================================The following describes the additional PHP functions.All keywords are case-insensitive.o i18n_http_output(encoding)o encoding = i18n_http_output() This will set the http output encoding. Any output following this function will be controlled by this function. If no argument is given, the current http output encode setting is returned. encodings EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 pass: no conversion NONE is not allowedo encoding = i18n_internal_encoding() Returns the current internal encoding as a string. internal encoding EUC-JP : EUC SJIS: SJIS UTF-8: UTF-8o encoding = i18n_http_input() Returns http input encoding. encodings EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 pass: no conversion (only if i18n.http_input is set to pass)o string = i18n_convert(string, encoding) string = i18n_convert(string, encoding, pre-conversion-encoding) Returns converted string in desired encoding. If pre-conversion-encoding is not defined, the given string is assumed to be in internal encoding. encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 pass: no conversion pre-conversion-encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 pass: no conversion auto: auto detectiono encoding = i18n_discover_encoding(string) Encoding of the given string is returned (as a string). encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 ASCII: ASCII (only 09h, 0Ah, 0Dh, 20h-7Eh) pass: unable to determine (text is too short to determine) unknown: unknown or possible erroro int = mbstrlen(string)o int = mbstrlen(string, encoding) Returns character length of a given string. If no encoding is defined, the encoding of string is assumed to be the internal encoding. encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8 auto: automatico int = mbstrpos(string1, string2)o int = mbstrpos(string1, string2, start)o int = mbstrpos(string1, string2, start, encoding) Same as strpos. If no encoding is defined, the encoding of string is assumed to be the internal encoding. encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8o int = mbstrrpos(string1, string2)o int = mbstrrpos(string1, string2, encoding) Same as strrpos. If no encoding is defined, the encoding of string is assumed to be the internal encoding. encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8o string = mbsubstr(string, position)o string = mbsubstr(string, position, length)o string = mbsubstr(string, position, length, encoding) Same as substr. If no encoding is defined, the encoding of string is assumed to be the internal encoding. encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8o string = mbstrcut(string, position)o string = mbstrcut(string, position, length)o string = mbstrcut(string, position, length, encoding) Same as subcut. If position is the 2nd byte of a mb character, it will cut from the first byte of that character. It will cut the string without chopping a single byte from a mb character. In another words, if you set length to 5, you will only get two mb characters. If no encoding is defined, the encoding of string is assumed to be the internal encoding. encoding EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8o string = i18n_mime_header_encode(string) MIME encode the string in the format of =?ISO-2022-JP?B?[string]?=.o string = i18n_mime_header_decode(string) MIME decodes the string.o string = i18n_ja_jp_hantozen(string)o string = i18n_ja_jp_hantozen(string, option)o string = i18n_ja_jp_hantozen(string, option, encoding) Conversion between full width character and halfwidth character. option The following options are allowed. The default is "KV". Acronym: FW = fullwidth, HW = halfwidth "r" : FW alphabet -> HW alphabet "R" : HW alphabet -> FW alphabet "n" : FW number -> HW number "N" : HW number -> FW number "a" : FW alpha numeric (21h-7Eh) -> HW alpha numeric "A" : HW alpha numeric (21h-7Eh) -> FW alpha numeric "k" : FW katakana -> HW katakana "K" : HW katakana -> FW katakana "h" : FW hiragana -> HW hiragana "H" : HW hiragana -> FW katakana "c" : FW katakana -> FW hiragana "C" : FW hiragana -> FW katakana "V" : merge dakuon character. only works with "K" and "H" option encoding If no encoding is defined, the encoding of string is assumed to be the internal encoding. EUC-JP : EUC SJIS: SJIS JIS : JIS UTF-8: UTF-8int = mbereg(regex_pattern, string, string)int = mberegi(regex_pattern, string, string) mb version of ereg() and eregi()string = mbereg_replace(regex_pattern, string, string)string = mberegi_replace(regex_pattern, string, string) mb version of ereg_replace() and eregi_replace()string_array = mbsplit(regex, string, limit) mb version of split()========================================== FAQ==========================================Here, we have gathered some commonly asked questions on PHP-jp mailinglist.o To use Japanese in GET methodIf you need to assign Japanese text in GET method with argument, such as;xxxx.php?data=<Japanese text>, use urlencode function in PHP. If not,text may not be passed onto action php properly.ex: <a href="hoge.php?data=<? echo urlencode($data) ?>">Link</a>o When passing data via GET/POST/COOKIE, \ character sneaks inWhen using SJIS as internal encoding, or passed-on data includes '"\, PHP automatically inserts escaping character, \. Set magic_quotes_gpcin php3.ini from On to Off. An alternative work around to this problem is to use StripSlashes().If $quote_str is in SJIS and you would like to extract Japanese text,use ereg_replace as follows:ereg_replace(sprintf("([%c-%c%c-%c]\\\\)\\\\",0x81,0x9f,0xe0,0xfc), "\\1",$quote_str);This will effectively extract Japanese text out of $quote_str.o Sometimes, encoding detection failsIf i18n_http_input() returns 'pass', it's likely that PHP failed todetect whether it's SJIS or EUC. In such case, use <input type=hiddenvalue="some Japanese text"> to properly detect the incoming text's encoding.========================================== Japanese Manual==========================================Translated manual done by "PHP Japanese Manual Project" :http://www.php.net/manual/ja/manual.phpStarting 3.0.18-i18n-ja, we have removed doc-jp from tarball package.========================================== Change Logs==========================================o 2000-10-28, Rui Hirokawa <hirokawa@php.net>This patch is derived from php-3.0.15-i18n-ja as well as php-3.0.16 by Kuwamura applied to original php-3.0.18. It also includes following fixes:1) allows you to set charset in mail().2) fixed mbregex definitions to avoid conflicts with system regex3) php3.ini-dist now uses PASS for http_output instead of SJISo 2000-11-24, Hironori Sato <satoh@yyplanet.com>Applied above patched and added detection for gdImageStringTTF in configure.Following setups are known to work:gd-1.3-6, gd-devel-1.3-6, freetype-1.3.1-5, freetype-devel-1.3.1-5 ImageTTFText($im,$size,$angle,$x1,$y1,$color,"/path/to/font.ttf", i18n_convert("泣塑胳", "UTF-8")); ImageGif($im);gd-1.7.3-1k1, gd-devel-1.7.3-1k1, freetype-1.3.1-5, freetype-devel-1.3.1-5 ImageTTFText($im,$size,$angle,$x1,$y1,$color,"/path/to/font.ttf","泣塑胳"); ImagePng($im); * i18n_internal_encoding = EUC 唆は SJISFor any gd libraries before 1.6.2, you need to use i18n_convert. Forgd-1.5.2/3, upgrade to anything above 1.7 to use ImageTTFText withoutusing i18n_convert. As long as you have internal_encoding set to EUC orSJIS, ImageTTFText should work without mojibake. Again, make sure you have i18n_http_output("pass") before calling ImageGif, ImagePng, ImageJpeg!o 2000-12-09, Rui Hirokawa <hirokawa@php.net>Fixed mail() which was causing segmentation fault when header was null.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -