Skip to content

Commit 5b0156b

Browse files
committed
Use case-insensitive comparison when checking \N escapes
1 parent 23e6d3b commit 5b0156b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Literals using the ``\N{name}`` escape syntax can now construct CJK
2+
ideographs and Hangul syllables using case-insensitive names.

Modules/unicodedata.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ find_syllable(const char *str, int *len, int *pos, int count, int column)
11811181
len1 = Py_SAFE_DOWNCAST(strlen(s), size_t, int);
11821182
if (len1 <= *len)
11831183
continue;
1184-
if (strncmp(str, s, len1) == 0) {
1184+
if (PyOS_strnicmp(str, s, len1) == 0) {
11851185
*len = len1;
11861186
*pos = i;
11871187
}
@@ -1219,7 +1219,7 @@ _getcode(PyObject* self,
12191219
unsigned int i, incr;
12201220

12211221
/* Check for hangul syllables. */
1222-
if (strncmp(name, "HANGUL SYLLABLE ", 16) == 0) {
1222+
if (PyOS_strnicmp(name, "HANGUL SYLLABLE ", 16) == 0) {
12231223
int len, L = -1, V = -1, T = -1;
12241224
const char *pos = name + 16;
12251225
find_syllable(pos, &len, &L, LCount, 0);
@@ -1237,7 +1237,7 @@ _getcode(PyObject* self,
12371237
}
12381238

12391239
/* Check for unified ideographs. */
1240-
if (strncmp(name, "CJK UNIFIED IDEOGRAPH-", 22) == 0) {
1240+
if (PyOS_strnicmp(name, "CJK UNIFIED IDEOGRAPH-", 22) == 0) {
12411241
/* Four or five hexdigits must follow. */
12421242
v = 0;
12431243
name += 22;

0 commit comments

Comments
 (0)