Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request improves file path handling in Xdebug on Windows by ensuring proper conversion of Shift_JIS-encoded filenames to UTF-8.
Previously, Shift_JIS-encoded paths could not be correctly represented as file URIs, which caused debugger connection failures and incorrect file references when working with non-UTF-8 environments (e.g., PHP source files in Shift_JIS).
Background
On Windows systems using Shift_JIS locale,
__FILE__and related filenames in PHP source code are encoded in Shift_JIS.Xdebug expected these to be UTF-8, leading to garbled paths or invalid URIs (e.g., during DBGp communication).
This patch adds encoding detection and proper conversion before generating file URIs.
Changes
src/base/base.cAdded UTF-8 filename preparation for Windows builds:
src/debugger/handler_dbgp.cReplaced manual URL encoding with:
src/lib/usefulstuff.cAdded new helper functions:
xdebug_is_valid_utf8(const char *str)xdebug_is_valid_shiftjis(const char *str)xdebug_is_valid_encoding(const char *str)→ Detects UTF-8, Shift_JIS, or Unknown
xdebug_shiftjis_to_utf8(const char *sjis_str)→ Converts Shift_JIS string to UTF-8 using
MultiByteToWideChar/WideCharToMultiBytexdebug_prepare_filename(const char *filename)→ Converts filename to UTF-8 if necessary
xdebug_lowercase_drive_letter(char *fileuri)→ Normalizes drive letter casing in file URIs
Impact
#if PHP_WIN32)Testing
Credits
Authored by @chimorium
Discussed and refined with ChatGPT (context: Shift_JIS path issue in Xdebug)