Skip to content

Commit 115fcac

Browse files
fangerertimfel
authored andcommitted
Fix: convert Java enc name and fallback to utf-8
1 parent e149ddb commit 115fcac

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContextFunctions.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,16 @@ static Object doGeneric(GraalHPyContext hpyContext, Object charPtr,
18751875

18761876
@TruffleBoundary
18771877
static Encoding getFSDefault() {
1878-
return Encoding.fromJCodingName(System.getProperty("file.encoding"));
1878+
String fileEncoding = System.getProperty("file.encoding");
1879+
if (fileEncoding != null) {
1880+
try {
1881+
return Encoding.valueOf(fileEncoding.replace('-', '_'));
1882+
} catch (IllegalArgumentException e) {
1883+
// avoid any fatal Java exceptions; fall through
1884+
}
1885+
}
1886+
// fall back to UTF-8
1887+
return Encoding.UTF_8;
18791888
}
18801889
}
18811890

0 commit comments

Comments
 (0)