What is the usage of "mbstring.script_encoding" config? Is it diffrent from mbstring.internal_encoding?
Asked
Active
Viewed 1,274 times
1 Answers
1
It is zend.script_encoding
now. Let me show you an example.
I have a script written in 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'));
In my INIes I already have the config:
mbstring.encoding_translation = On
mbstring.internal_encoding = UTF-8
Script test
bool(false)
bool(true)
Where $input
is a Cyrillic string %D0%F3%F1%F1%EA%E8%E9
.
Now let us change configuration for script encoding. In php.ini
(or in another INIes. It depends on your sys config) you can find lines like
; 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
By default all these lines are commented. Here I set multibyte
to On
and script encoding to CP1251
. Do a test again.
Script test
bool(true)
bool(true)
So... we just easily migrated to UTF-8 :)

nkamm
- 627
- 5
- 14
-
1Thanks, But can you please explain it a little more – Webber Nov 23 '12 at 10:26
-
@nkamm, I cannot replicate your behavior. The first script test gives me `bool(true)`. This answer is very unclear: So you added zend.multibyte = On and zend.script_encoding = CP1251 and it migrated to UTF-8? Why? – Pacerier Oct 27 '14 at 08:19