summaryrefslogtreecommitdiff
path: root/win32/codepage.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove proto comments from C filesMax Semenik2020-07-061-8/+4
| | | | Closes GH-5758
* Use ZPP int|string and add ValueError for Windows codepagesGeorge Peter Banyard2020-05-041-41/+39
| | | | Closes GH-5517
* Use RETURN_THROWS() during ZPP in main, sapi, win32, and ZendMáté Kocsis2019-12-301-5/+5
|
* Remove mention of PHP major version in Copyright headersGabriel Caruso2019-09-251-2/+0
| | | | Closes GH-4732.
* Merge branch 'PHP-7.4'Nikita Popov2019-06-051-2/+6
|\
| * Allow exceptions in __toString()Nikita Popov2019-06-051-2/+6
| | | | | | | | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/tostring_exceptions And convert some object to string conversion related recoverable fatal errors into Error exceptions. Improve exception safety of internal code performing string conversions.
* | Merge branch 'PHP-7.4'Christoph M. Becker2019-05-091-3/+7
|\ \ | |/ | | | | | | * PHP-7.4: Fix erroneous assertions
| * Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2019-05-091-3/+7
| |\ | | | | | | | | | | | | * PHP-7.3: Fix erroneous assertions
| | * Merge branch 'PHP-7.2' into PHP-7.3Christoph M. Becker2019-05-091-4/+7
| | |\ | | | | | | | | | | | | | | | | * PHP-7.2: Fix erroneous assertions
| | | * Fix erroneous assertionsChristoph M. Becker2019-05-091-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since PHP strings are binary safe (i.e. they may contain NUL bytes), we must not assume that strlen()/wcslen() actually return the length of the string. Only if the given in_len is zero, it is safe to assert this.
| | | * Trim trailing whitespace in source code filesPeter Kokot2018-10-131-6/+6
| | | |
| | | * year++Xinchen Hui2018-01-021-1/+1
| | | |
| | * | Trim trailing whitespace in source code filesPeter Kokot2018-10-131-1/+1
| | | |
* | | | Merge branch 'PHP-7.4'Anatol Belski2019-04-011-12/+14
|\ \ \ \ | |/ / / | | | | | | | | | | | | * PHP-7.4: Improve ascii check
| * | | Improve ascii checkAnatol Belski2019-04-011-12/+14
| | | |
* | | | No need for scoping anymoreAnatol Belski2019-03-301-8/+4
|/ / /
* | | Implement FR #77377 handle CTRL+C in WindowsAnatol Belski2019-02-081-8/+5
| | |
* | | Remove local variablesPeter Kokot2019-02-031-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the so called local variables defined per file basis for certain editors to properly show tab width, and similar settings. These are mainly used by Vim and Emacs editors yet with recent changes the once working definitions don't work anymore in Vim without custom plugins or additional configuration. Neither are these settings synced across the PHP code base. A simpler and better approach is EditorConfig and fixing code using some code style fixing tools in the future instead. This patch also removes the so called modelines for Vim. Modelines allow Vim editor specifically to set some editor configuration such as syntax highlighting, indentation style and tab width to be set in the first line or the last 5 lines per file basis. Since the php test files have syntax highlighting already set in most editors properly and EditorConfig takes care of the indentation settings, this patch removes these as well for the Vim 6.0 and newer versions. With the removal of local variables for certain editors such as Emacs and Vim, the footer is also probably not needed anymore when creating extensions using ext_skel.php script. Additionally, Vim modelines for setting php syntax and some editor settings has been removed from some *.phpt files. All these are mostly not relevant for phpt files neither work properly in the middle of the file.
* | | Remove yearly range from copyright noticeZeev Suraski2019-01-301-1/+1
| | |
* | | Trim trailing whitespace in source code filesPeter Kokot2018-10-131-1/+1
|/ /
* | Reduce var scopeAnatol Belski2018-02-191-2/+1
| |
* | Fix some misspellingsGabriel Caruso2018-02-061-1/+1
| |
* | Fix visibilityAnatol Belski2018-02-051-2/+5
| |
* | Reimplement ASCII conversion using aligned routineAnatol Belski2018-01-241-27/+54
| |
* | Implement SSE2 based ASCII to UTF-16 conversionAnatol Belski2018-01-191-42/+20
| | | | | | | | This also eliminates the INT_MAX length restriction.
* | Trailing whitespacesGabriel Caruso2018-01-031-6/+6
| | | | | | | | Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
* | year++Xinchen Hui2018-01-021-1/+1
| |
* | Refactor ASCII to wide conversionAnatol Belski2017-11-161-43/+48
| | | | | | | | | | - add SSE2 based ASCII check in 16 byte blocks - use early return on fail
* | Unroll loop for ASCII checkAnatol Belski2017-11-151-4/+28
|/
* improve and generalize the recognition of a cli sapiAnatol Belski2017-01-081-3/+8
|
* Update copyright headers to 2017Sammy Kaye Powers2017-01-041-1/+1
|
* add foldsAnatol Belski2016-12-211-2/+2
|
* fix possible null dereferenceAnatol Belski2016-12-211-8/+10
|
* deliver the real cp also if a constant is passedAnatol Belski2016-12-201-0/+11
|
* chance CLI codepage, only when SAPI is initializedAnatol Belski2016-12-161-1/+7
| | | | | | | | | | | | 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.
* Care about intput and output encoding, as per default encoding RFCAnatol Belski2016-12-141-10/+47
| | | | | | | | | | | | | | | | | If PHP CLI is used with programs with no Unicode support, the default PHP console codepage might cause backward incompatible behaviors. This is solved with this patch by separating the handling of I/O codepage. As per https://wiki.php.net/rfc/default_encoding input_encodnig and output_encoding are centralized INI settings, so they're used for the purpose of adjusting the codepage. This gives user the ability to use UTF-8 internally, while letting the system API to convert the output to a compatible codepage. This also might solve the font issues on systems without good true type support. Note, that there no change to the default behavior - if input and output encoding are not set, which is the default case, the default charset applies to both console input and output. The patch is just a compilment to the backward compatibility, not more and not less.
* add parenthesesAnatol Belski2016-08-271-1/+1
|
* check malloc resultAnatol Belski2016-08-081-0/+4
|
* fix typoAnatol Belski2016-07-291-5/+5
|
* add more errno handlingAnatol Belski2016-07-291-2/+16
|
* fix cli codepage resetAnatol Belski2016-07-111-1/+1
|
* Fixed the UTF-8 and long path support in the streams on Windows.Anatol Belski2016-06-201-0/+600
Since long the default PHP charset is UTF-8, however the Windows part is out of step with this important point. The current implementation in PHP doesn't technically permit to handle UTF-8 filepath and several other things. Till now, only the ANSI compatible APIs are being used. Here is more about it https://msdn.microsoft.com/en-us/library/windows/desktop/dd317752%28v=vs.85%29.aspx The patch fixes not only issues with multibyte filenames under incompatible codepages, but indirectly also issues with some other multibyte encodings like BIG5, Shift-JIS, etc. by providing a clean way to access filenames in UTF-8. Below is a small list of issues from the bug tracker, that are getting fixed: https://bugs.php.net/63401 https://bugs.php.net/41199 https://bugs.php.net/50203 https://bugs.php.net/71509 https://bugs.php.net/64699 https://bugs.php.net/64506 https://bugs.php.net/30195 https://bugs.php.net/65358 https://bugs.php.net/61315 https://bugs.php.net/70943 https://bugs.php.net/70903 https://bugs.php.net/63593 https://bugs.php.net/54977 https://bugs.php.net/54028 https://bugs.php.net/43148 https://bugs.php.net/30730 https://bugs.php.net/33350 https://bugs.php.net/35300 https://bugs.php.net/46990 https://bugs.php.net/61309 https://bugs.php.net/69333 https://bugs.php.net/45517 https://bugs.php.net/70551 https://bugs.php.net/50197 https://bugs.php.net/72200 https://bugs.php.net/37672 Yet more related tickets can for sure be found - on bugs.php.net, Stackoverflow and Github. Some of the bugs are pretty recent, some descend to early 2000th, but the user comments in there last even till today. Just for example, bug #30195 was opened in 2004, the latest comment in there was made in 2014. It is certain, that these bugs descend not only to pure PHP use cases, but get also redirected from the popular PHP based projects. Given the modern systems (and those supported by PHP) are always based on NTFS, there is no excuse to keep these issues unresolved. The internalization approach on Windows is in many ways different from UNIX and Linux, while it supports and is based on Unicode. It depends on the current system code page, APIs used and exact kind how the binary was compiled The locale doesn't affect the way Unicode or ANSI API work. PHP in particular is being compiled without _UNICODE defined and this is conditioned by the way we handle strings. Here is more about it https://msdn.microsoft.com/en-us/library/tsbaswba.aspx However, with any system code page ANSI functions automatically convert paths to UTF-16. Paths in some encodings incompatible with the current system code page, won't work correctly with ANSI APIs. PHP till now only uses the ANSI Windows APIs. For example, on a system with the current code page 1252, the paths in cp1252 are supported and transparently converted to UTF-16 by the ANSI functions. Once one wants to handle a filepath encoded with cp932 on that particular system, an ANSI or a POSIX compatible function used in PHP will produce an erroneous result. When trying to convert that cp932 path to UTF-8 and passing to the ANSI functions, an ANSI function would likely interpret the UTF-8 string as some string in the current code page and create a filepath that represents every single byte of the UTF-8 string. These behaviors are not only broken but also disregard the documented INI settings. This patch solves the issies with the multibyte paths on Windows by intelligently enforcing the usage of the Unicode aware APIs. For functions expect Unicode (fe CreateFileW, FindFirstFileW, etc.), arguments will be converted to UTF-16 wide chars. For functions returning Unicode aware data (fe GetCurrentDirectoryW, etc.), resulting wide string is converted back to char's depending on the current PHP charset settings, either to the current ANSI codepage (this is the behavior prior to this patch) or to UTF-8 (the default behavior). In a particular case, users might have to explicitly set internal_encoding or default_charset, if filenames in ANSI codepage are necessary. Current tests show no regressions and witness that this will be an exotic case, the current default UTF-8 encoding is compatible with any supported system. The dependency libraries are long switching to Unicode APIs, so some tests were also added for extensions not directly related to streams. At large, the patch brings over 150 related tests into the core. Those target and was run on various environments with European, Asian, etc. codepages. General PHP frameworks was tested and showed no regressions. The impact on the current C code base is low, the most places affected are the Windows only places in the three files tsrm_win32.c, zend_virtual_cwd.c and plain_wrapper.c. The actual implementation of the most of the wide char supporting functionality is in win32/ioutil.* and win32/codepage.*, several low level functionsare extended in place to avoid reimplementation for now. No performance impact was sighted. As previously mentioned, the ANSI APIs used prior the patch perform Unicode conversions internally. Using the Unicode APIs directly while doing custom conversions just retains the status quo. The ways to optimize it are open (fe. by implementing caching for the strings converted to wide variants). The long path implementation is user transparent. If a path exceeds the length of _MAX_PATH, it'll be automatically prefixed with \\?\. The MAXPATHLEN is set to 2048 bytes. Appreciation to Pierre Joye, Matt Ficken, @algo13 and others for tips, ideas and testing. Thanks.