pybind / pybind/pybind11

[BUG]: This PR addresses recurring C4819 compiler warnings on Windows when using pybind11 with non-Unicode code pages (e.g., CP936):

Open
#5,863 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

Required prerequisites
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.