py4j
py4j copied to clipboard
UTF8 Filename error when passing parameters to Java function
- Java:
OutputStream outs = new FileOutputStream(new File(filePath)); outs.write(ostream.toByteArray()); outs.close();
- Python:
launch_gateway(redirect_stdout=redirect_stdout javaopts=["-Dfile.encoding=UTF-8", "-Dsun.jnu.encoding=UTF-8","-Duser.language=zh","-Duser.region=CN"]
filepath = "output/abc中文.doc"
- Java & Python Print:
output/abc中文.doc
- Output File:
[root output]# locale LANG=zh_CN.UTF-8 .... LC_ALL=zh_CN.UTF-8
[root output]# ls abc??.doc
Hi, we will need more details to help you:
- What is the Python (and possibly Java) code producing the error?
- What versions of Python, Java, OS are you using?
Normally, everything is encoded/decoded through UTF-8 (for examples, we had tests with accented characters), but obviously, I have little experience with this particular character set :-)
Hi, we will need more details to help you:
- What is the Python (and possibly Java) code producing the error?
- What versions of Python, Java, OS are you using?
Normally, everything is encoded/decoded through UTF-8 (for examples, we had tests with accented characters), but obviously, I have little experience with this particular character set :-)
[xx@xx libs]# python --version Python 2.7.5 [xx@xx libs]# java -version openjdk version "1.8.0_191" OpenJDK Runtime Environment (build 1.8.0_191-b12) OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
output:abc??.doc expect:abc中文.doc