com php-src: chance CLI codepage, only when SAPI is initialized: win32/codepage.c
| From: | Anatol Belski | Date: | Fri, 16 Dec 2016 15:49:18 +0000 |
| Subject: | com php-src: chance CLI codepage, only when SAPI is initialized: win32/codepage.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96342@lists.php.net to get a copy of this message | ||
Commit: b91d7f186acc7c107fa330bc8697c2cc98360e45
Author: Anatol Belski <ab@php.net> Fri, 16 Dec 2016 16:49:18 +0100
Parents: 8ba7878f1b88f760d1cf483321e2ac1b27a93c58
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b91d7f186acc7c107fa330bc8697c2cc98360e45
Log:
chance CLI codepage, only when SAPI is initialized
This finally solves issues with DBSC console codepages, and in
general improves the console codepage switching. When
module_initialized, all the possible encoding INI settings with
regard to possible modifications are set, and that's the
right moment to switch the console codepage in regard to I/O.
CJK glyphs might take more than 1 cell, so then visual issues
can occur, when switching console codepage back and forth. Users
are free to use ini_set(), but any visual issues are then up to
the user responsibility.
Changed paths:
M win32/codepage.c
Diff:
diff --git a/win32/codepage.c b/win32/codepage.c
index 511e428..f87d4c0 100644
--- a/win32/codepage.c
+++ b/win32/codepage.c
@@ -384,6 +384,8 @@ PW32CP wchar_t *php_win32_cp_env_any_to_w(const char* env)
static BOOL php_win32_cp_cli_io_setup(void)
{
+ BOOL ret = TRUE;
+
if (PG(input_encoding) && PG(input_encoding)[0]) {
cur_in_cp = php_win32_cp_get_by_enc(PG(input_encoding));
if (!cur_in_cp) {
@@ -402,7 +404,11 @@ static BOOL php_win32_cp_cli_io_setup(void)
cur_out_cp = cur_cp;
}
- return SetConsoleCP(cur_in_cp->id) && SetConsoleOutputCP(cur_out_cp->id);
+ if(php_get_module_initialized()) {
+ ret = SetConsoleCP(cur_in_cp->id) && SetConsoleOutputCP(cur_out_cp->id);
+ }
+
+ return ret;
}
PW32CP const struct php_win32_cp *php_win32_cp_do_setup(const char *enc)