#30333 [Com]: fscanf() and() not working correctly with other then English language

From: Date: Sat, 23 Oct 2004 14:00:47 +0000
Subject: #30333 [Com]: fscanf() and() not working correctly with other then English language
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-68000@lists.php.net to get a copy of this message
ID: 30333 Comment by: profic at nospam dot kursknet dot ru Reported By: altuhov at nm dot ru Status: Open Bug Type: Filesystem function related Operating System: WinXP SP2 PHP Version: 5.1.0-dev New Comment: Hm, russian letters converts to it's codes. I think this is even better then looking at ugly characters =) Previous Comments: ------------------------------------------------------------------------ [2004-10-23 15:53:35] profic at nospam dot kursknet dot ru E:\>ver Microsoft Windows XP [Version 5.1.2600] E:\>php -v PHP 5.0.2 (cli) (built: Sep 24 2004 01:25:41) Copyright (c) 1997-2004 The PHP Group Zend Engine v2.0.2, Copyright (c) 1998-2004 Zend Technologies with DBG v2.11.30, (C) 2000,2004, by Dmitri Dmitrienko E:\>chcp 866 Active code page: 866 E:\>php <?php $str = "&#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072;"; $arr = sscanf ($str, "%s %s %s"); print_r ($arr); ?> ^Z Array ( [0] => &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; [1] => &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; [2] => &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; ) E:\>chcp 1251 Active code page: 1251 E:\>php <?php $str = "&#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072;"; $arr = sscanf ($str, "%s %s %s"); print_r ($arr); ?> ^Z Array ( [0] => &#1087;&#1088; [1] => &#1074; [2] => &#1088; ) E:\>php <?php var_dump (setlocale (LC_ALL, "rus_RUS.1251")); $str = "&#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072; &#1087;&#1088;&#1086;&#1074;&#1077;&#1088;&#1082;&#1072;"; $arr = sscanf ($str, "%s %s %s"); print_r ($arr); ?> ^Z string(19) "Russian_Russia.1251" Array ( [0] => &#1087;&#1088; [1] => &#1074;&#1077;&#1088; [2] => &#1072; ) E:\>php test.php string(19) "Russian_Russia.1251" Array ( [0] => &#1087;&#1088; [1] => &#1074; [2] => &#1088; ) E:\> Some comments to listing above: All text here is in cp1251 (windows-1251). There are 2 codepages for russian in windows: cp866 (aka OEM/DOS) and cp1251 (aka ANSI/Windows). As Windows' console can change current input/output codepage on fly, it seems to explain this bug, as with cp866 it works well and it is default console (in which php-cli is runing), but with cp1251 does not. But last 2 examples seems strange as locale is setted exactly. The test.php file is copy of the last inline PHP-code ------------------------------------------------------------------------ [2004-10-12 19:47:32] altuhov at nm dot ru Yes. Windows-1251. Reproduce code was writed and saved in the "Notepad". ------------------------------------------------------------------------ [2004-10-12 19:40:43] iliaa@php.net Is the russian locale used by winxp the same locale as the one used by the document? ------------------------------------------------------------------------ [2004-10-07 08:23:18] altuhov at nm dot ru Yes. Windows XP SP2 English version, but Russian locale. ------------------------------------------------------------------------ [2004-10-07 01:11:56] iliaa@php.net If the system using russian locale? ------------------------------------------------------------------------ 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 http://bugs.php.net/30333 -- Edit this bug report at http://bugs.php.net/?id=30333&edit=1

« previous php.bugs (#68000) next »