gh-55531: Implement normalize_encoding in C (#136643)

Closes gh-55531
This commit is contained in:
Stan Ulbrych 2025-10-30 14:31:47 +00:00 committed by GitHub
parent 6826166280
commit a3ce2f77f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 123 additions and 22 deletions

View file

@ -178,7 +178,7 @@ _Py_mbrtowc(wchar_t *pwc, const char *str, size_t len, mbstate_t *pmbs)
#define USE_FORCE_ASCII
extern int _Py_normalize_encoding(const char *, char *, size_t);
extern int _Py_normalize_encoding(const char *, char *, size_t, int);
/* Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale
and POSIX locale. nl_langinfo(CODESET) announces an alias of the
@ -229,7 +229,7 @@ check_force_ascii(void)
}
char encoding[20]; /* longest name: "iso_646.irv_1991\0" */
if (!_Py_normalize_encoding(codeset, encoding, sizeof(encoding))) {
if (!_Py_normalize_encoding(codeset, encoding, sizeof(encoding), 1)) {
goto error;
}