Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I set file encoding to GBK? #195

Closed
zjulzq opened this issue Apr 6, 2016 · 13 comments
Closed

Can I set file encoding to GBK? #195

zjulzq opened this issue Apr 6, 2016 · 13 comments
Labels

Comments

@zjulzq
Copy link

zjulzq commented Apr 6, 2016

In my case, the header files are encoded with GBK. As a result, the java files contain messy code.

/////////////////////////////////////////////////////////////////////////
/**\system ��һ������ϵͳ
 * \company �Ϻ��ڻ���Ϣ�������޹�˾
 * \file ThostFtdcMdApi.h
 * \brief �����˿ͻ��˽ӿ�
 * \history 
 * 20060106 �Ժ��     �������ļ�
///////////////////////////////////////////////////////////////////////// */

I have tried -Dfile.encoding=GBK, but it does not work.

What shall I do?

@saudet
Copy link
Member

saudet commented Apr 6, 2016

-Dfile.encoding=GBK should work. Did you confirm that your version of Java supports GBK?

@zjulzq
Copy link
Author

zjulzq commented Apr 6, 2016

I print the available Charsets, it contains GBK.

Big5, Big5
Big5-HKSCS, Big5-HKSCS
EUC-JP, EUC-JP
EUC-KR, EUC-KR
GB18030, GB18030
GB2312, GB2312
GBK, GBK
IBM-Thai, IBM-Thai
IBM00858, IBM00858
IBM01140, IBM01140
......

@saudet
Copy link
Member

saudet commented Apr 6, 2016

I'm more familiar with Japanese, so I tried SHIFT_JIS this way:

$ java -Dfile.encoding=SHIFT_JIS -jar javacpp.jar LibraryName

And it works just fine!

@zjulzq
Copy link
Author

zjulzq commented Apr 7, 2016

My command is

mvn clean install -Dfile.encoding=GBK -Djavacpp.platform=linux-x86_64 -Djavacpp.platform.dependency=false -Djavacpp.cppbuild.skip=true --projects .,ctp

Will your javacpp plugin pick the -Dfile.encoding=UTF-8?

@saudet
Copy link
Member

saudet commented Apr 7, 2016

Not sure, we might have to set the MAVEN_OPTS or _JAVA_OPTIONS environment variable for that...

@zjulzq
Copy link
Author

zjulzq commented Apr 7, 2016

I solve it by this:

export JAVA_TOOL_OPTIONS="-Dfile.encoding=GBK"

@zjulzq zjulzq closed this as completed Apr 7, 2016
@saudet
Copy link
Member

saudet commented Apr 7, 2016

Cool! Thanks for testing :)

@saudet saudet added the question label Apr 7, 2016
@zjulzq zjulzq reopened this Apr 10, 2016
@zjulzq
Copy link
Author

zjulzq commented Apr 10, 2016

There is another problem.

After I set file.encoding to GBK, another problem occurs. I meet this problem after you have fixed thetypedef char Thost*Type[32] bug. #192

[ERROR] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcMdApi.java:16660: error: unmappable character for encoding UTF-8
[ERROR] /**??????? */
[ERROR] ^
[ERROR] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcMdApi.java:16660: error: unmappable character for encoding UTF-8
[ERROR] /**??????? */
[ERROR] ^
[ERROR] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcMdApi.java:16660: error: unmappable character for encoding UTF-8
[ERROR] /**??????? */
[ERROR] ^
[ERROR] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcMdApi.java:16660: error: unmappable character for encoding UTF-8
[ERROR] /**??????? */

/**??????? */ are comments. These comments are written in Chinese.

@saudet
Copy link
Member

saudet commented Apr 10, 2016

That sounds like an issue with the Java compiler? Make sure you don't force it to UTF-8 in your pom.xml file.

@zjulzq
Copy link
Author

zjulzq commented Apr 10, 2016

I set project.build.sourceEncoding to GBK in parent pom.xml to solve it.

<project.build.sourceEncoding>GBK</project.build.sourceEncoding>

@zjulzq
Copy link
Author

zjulzq commented Apr 10, 2016

There are some warnings, but not fatal. @param followed by param name and chinese comment can not be parsed.

They are Javadoc warnings.

[WARNING] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcMdApi.java:135: warning - @param argument "pszFrontAddress��ǰ�û�������ַ��" is not a parameter name.
[WARNING] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcMdApi.java:144: warning - @param argument "pszNsAddress�����ַ�����������ַ��" is not a parameter name.
[WARNING] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcMdApi.java:150: warning - @param argument "pFensUserInfo���û���Ϣ��" is not a parameter name.
[WARNING] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcTraderApi.java:416: warning - @param argument "pszFrontAddress��ǰ�û�������ַ��" is not a parameter name.
[WARNING] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcTraderApi.java:425: warning - @param argument "pszNsAddress�����ַ�����������ַ��" is not a parameter name.
[WARNING] /home/lzq/workspace/javacpp-presets/ctp/src/main/java/org/bytedeco/javacpp/ThostFtdcTraderApi.java:431: warning - @param argument "pFensUserInfo���û���Ϣ��" is not a parameter name.

@saudet
Copy link
Member

saudet commented Apr 10, 2016 via email

@zjulzq
Copy link
Author

zjulzq commented Apr 11, 2016

I don't think it is a good solution to set encoding along the tool chains. So, I convert the original header files from GBK to UTF-8, in order to avoid the encoding problem.

@zjulzq zjulzq closed this as completed Apr 11, 2016
saudet added a commit to bytedeco/javacpp that referenced this issue Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants