「mbstring.script_encoding」構成の使用法は何ですか? mbstring.internal_encoding とは違いますか?
1207 次
1 に答える
1
今zend.script_encoding
です。例を示しましょう。
CP1251 で書かれたスクリプトがあります。
// script encoded as ANSI. var_dump() says false
var_dump(mb_check_encoding('Кириллица', 'UTF-8'));
$input = $_GET['internalInput'];
var_dump(mb_check_encoding($input, 'UTF-8'));
私の INIes には、すでに構成があります。
mbstring.encoding_translation = On
mbstring.internal_encoding = UTF-8
スクリプト テスト
bool(false)
bool(true)
はキリル$input
文字列%D0%F3%F1%F1%EA%E8%E9
です。
次に、スクリプト エンコーディングの構成を変更しましょう。(php.ini
または別のINIes。システム構成によって異なります)で、次のような行を見つけることができます
; If enabled, scripts may be written in encodings that are incompatible with
; the scanner. CP936, Big5, CP949 and Shift_JIS are the examples of such
; encodings. To use this feature, mbstring extension must be enabled.
; Default: Off
zend.multibyte = On
; Allows to set the default encoding for the scripts. This value will be used
; unless "declare(encoding=...)" directive appears at the top of the script.
; Only affects if zend.multibyte is set.
; Default: ""
zend.script_encoding = CP1251
デフォルトでは、これらの行はすべてコメント化されています。ここでは に設定multibyte
しOn
、スクリプト エンコーディングをに設定しCP1251
ます。もう一度テストを行います。
スクリプト テスト
bool(true)
bool(true)
だから...簡単にUTF-8に移行しました:)
于 2012-11-20T10:39:32.373 に答える