Skip to content

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

@bienanguo

Description

@bienanguo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNew bug, unverified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions