[BUG]: This PR addresses recurring C4819 compiler warnings on Windows when using pybind11 with non-Unicode code pages (e.g., CP936):
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
What version (or hash if on master) of pybind11 are you using?
pybind11-3.0.1
Problem description
Replace non-ASCII characters in comments with ASCII equivalents to fix C4819 warnings on Windows.
This PR addresses recurring C4819 compiler warnings on Windows when using pybind11 with non-Unicode code pages (e.g., CP936):
warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss.
The warnings are triggered by a few non-ASCII Unicode characters (e.g., en-dash –, em-dash —, smart quotes, or mathematical symbols) present in source comments. While harmless, these warnings clutter build logs—especially in large projects or CI pipelines—and may confuse new users.
This change:
Replaces all non-ASCII characters in comments only with standard ASCII equivalents (e.g., – → -, “/” → ", ‘/’ → ').
Does not modify any code, identifiers, string literals, or functionality.
Maintains comment clarity and readability.
Improves compatibility with legacy Windows toolchains without requiring file encoding changes.
Files affected:
include/pybind11/cast.h
include/pybind11/detail/struct_smart_holder.h
(and any other files found to contain non-ASCII comment characters)
This is a purely cosmetic and compatibility-focused change with zero runtime impact.
Fixes: (optional: reference an issue if one exists, e.g., #XXXX)
Reproducible example code
Is this a regression? Put the last known working version here if it is.
Not a regression
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with include/pybind11/cast.h and include/pybind11/detail/struct_smart_holder.h, then search the source tree for non-ASCII characters in comments. Replace only comment characters with ASCII equivalents, leaving code, identifiers, string literals, and functionality unchanged. Done means the affected comments no longer trigger the reported Windows C4819 warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100