Req->Bug #74777 [Opn->Nab]: automatically convert all strings given in php script file

From: Date: Sun, 18 Jun 2017 16:39:33 +0000
Subject: Req->Bug #74777 [Opn->Nab]: automatically convert all strings given in php script file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209581@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74777&edit=1 ID: 74777 Updated by: requinix@php.net Reported by: qdinar at gmail dot com Summary: automatically convert all strings given in php script file -Status: Open +Status: Not a bug -Type: Feature/Change Request +Type: Bug Package: *General Issues Operating System: windows 10 PHP Version: 5.6.30 Block user comment: N Private report: N New Comment: The string is converted at compile time. That means mbstring.internal_encoding has to be set to the desired encoding before the file is even loaded. <?php // first.php mb_internal_encoding('windows-1251'); // or set in php.ini include 'second.php'; ?> <?php // second.php declare(encoding='utf-8'); file_put_contents('declare_encoding.txt', 'сэлэм'); ?> Previous Comments: ------------------------------------------------------------------------ [2017-06-18 16:26:44] qdinar at gmail dot com Description: ------------ i use one-byte encoding for script's calculations, and want to provide one-byte strings, but i want to write php code itself in utf-8 because i use non-windows-1251 characters in comments. i have tried "declare(encoding='utf-8');" for that but seems it does not work that way, see example below. i tried that because it is written at http://php.net/manual/en/ini.core.php#ini.zend.script-encoding : " Literal strings will be transliterated from zend.script_enconding to mbstring.internal_encoding, as if mb_convert_encoding() would have been called. " and i thought that maybe " declare(encoding='utf-8'); " sets same "zend.script_enconding" but just for a separate file. (they are somehow related, as i have seen from docs). i do not want to have set it to all files. Test script: --------------- php script file in utf-8 encoding: <?php declare(encoding='utf-8'); mb_internal_encoding('windows-1251'); file_put_contents( 'declare_encoding.txt' , "сэлэм"); ?> Expected result: ---------------- "сэлэм" written with windows-1251 Actual result: -------------- "сэлэм" written with utf-8 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74777&edit=1

« previous php.bugs (#209581) next »