Bug #74777 [Com]: automatically convert all strings given in php script file

From: Date: Mon, 19 Jun 2017 11:51:54 +0000
Subject: Bug #74777 [Com]: automatically convert all strings given in php script file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209590@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 Comment by: qdinar at gmail dot com Reported by: qdinar at gmail dot com Summary: automatically convert all strings given in php script file Status: Not a bug Type: Bug Package: *General Issues Operating System: windows 10 PHP Version: 5.6.30 Block user comment: N Private report: N New Comment: >@ini_set('mbstring.internal_encoding', 'windows-1251'); it works in php 5.6.30. thank you. Previous Comments: ------------------------------------------------------------------------ [2017-06-18 23:10:51] nikic@php.net IIRC there's also an issue where you cannot use internal_encoding, but have to use the deprecated mbstring.internal_encoding :/ ------------------------------------------------------------------------ [2017-06-18 23:03:05] requinix@php.net I did, but what I posted is not technically what I tried and I then made a couple assumptions that weren't true. I'm working on creating a new bug report about problems in file conversion with regards to mbstring.internal_encoding, mb_internal_encoding(), default_charset, and internal_encoding, however I'm still trying to understand exactly what does and does not work (and why) and it's taking longer than I thought. I considered this bug report to be about how to use zend.multibyte correctly, and after looking through the documentation I see it talks about the mbstring.internal_encoding setting - not mb_internal_encoding(). Including what I said before about changing the encoding before the file is parsed, this revised code <?php // first.php @ini_set('mbstring.internal_encoding', 'windows-1251'); include 'second.php'; ?> <?php // second.php saved in UTF-8 declare(encoding = 'utf-8'); file_put_contents('declare_encoding.txt', 'сэлэм'); ?> should - and does - work correctly in PHP 7. (It should work in PHP 5.6 too but that series is no longer in active support.) ------------------------------------------------------------------------ [2017-06-18 20:57:49] qdinar at gmail dot com requinix, i have tried that, with php script including other, it has not worked: output is still in utf-8. have you tried it? ------------------------------------------------------------------------ [2017-06-18 20:46:20] qdinar at gmail dot com related bug: https://bugs.php.net/bug.php?id=68284 "declare encoding docs unclear / encoding handling needs better docs" ------------------------------------------------------------------------ [2017-06-18 16:39:32] requinix@php.net 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', 'сэлэм'); ?> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=74777 -- Edit this bug report at https://bugs.php.net/bug.php?id=74777&edit=1

« previous php.bugs (#209590) next »