File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
com.oracle.graal.python/src/com/oracle/graal/python/util Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public static Charset getCharset(String encoding) {
26
26
}
27
27
28
28
private static String normalize (String encoding ) {
29
- return encoding .toLowerCase (Locale .ENGLISH ).replaceAll ("\\ W +" , "_" );
29
+ return encoding .toLowerCase (Locale .ENGLISH ).replaceAll ("[^ \\ w.] +" , "_" );
30
30
}
31
31
32
32
private static Charset getJavaCharset (String name ) {
Original file line number Diff line number Diff line change @@ -50,8 +50,22 @@ def register(search_function):
50
50
__codec_search_path__ .append (search_function )
51
51
52
52
53
- def __normalizestring (string ):
54
- return string .replace (' ' , '-' ).lower ()
53
+ def __normalizestring (encoding ):
54
+ # Copied from encodings.normalize_encoding + added lowercasing
55
+ if isinstance (encoding , bytes ):
56
+ encoding = ascii_decode (encoding )[0 ]
57
+
58
+ chars = []
59
+ punct = False
60
+ for c in encoding :
61
+ if c .isalnum () or c == '.' :
62
+ if punct and chars :
63
+ chars .append ('_' )
64
+ chars .append (c .lower ())
65
+ punct = False
66
+ else :
67
+ punct = True
68
+ return '' .join (chars )
55
69
56
70
57
71
@__graalpython__ .builtin
You can’t perform that action at this time.
0 commit comments