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

Support for Chinese characters #34

Closed
zzustu opened this issue Jun 6, 2019 · 4 comments
Closed

Support for Chinese characters #34

zzustu opened this issue Jun 6, 2019 · 4 comments

Comments

@zzustu
Copy link

zzustu commented Jun 6, 2019

final String fileNameString = fileHeader.getFileNameString();

使用fileHeader.getFileNameString()获取FileName中文会乱码,而使用
fileHeader.getFileNameW()
就不乱码

@sunny-shu
Copy link
Contributor

sunny-shu commented Jul 14, 2020

i have reproduced the problem,and found why does it happen. i will submit a PR to fix it soon.but i dont know if the author will accept it.

@sunny-shu
Copy link
Contributor

sunny-shu commented Jul 15, 2020

@beothorn

if (isUnicode()) {
    int length = 0;
    fileName = "";
    fileNameW = "";
    while (length < fileNameBytes.length
           && fileNameBytes[length] != 0) {
        length++;
    }
    byte[] name = new byte[length];
    System.arraycopy(fileNameBytes, 0, name, 0, name.length);
    fileName = new String(name);
    if (length != nameSize) {
        length++;
        fileNameW = FileNameDecoder.decode(fileNameBytes, length);
    }
} else {
    fileName = new String(fileNameBytes);
    fileNameW = "";
}

I know when LHD_UNICODE is set.the filename consist of local coding name and unicode coding name.
in your code what charset you used to decode for "FileNameDecoder.decode(fileNameBytes, length);"

@gotson
Copy link
Member

gotson commented Jul 16, 2020

@sunny-shu beothorn is not maintaining the project, i am taking over. I am happy to have a look at your PR, we can also add a test file in the test scenarios to make sure it works fine.

@gotson gotson changed the title 打印日志中文乱码 Support for Chinese characters Jul 16, 2020
@gotson gotson closed this as completed in b6da583 Jul 28, 2020
gotson pushed a commit that referenced this issue Jul 28, 2020
# [7.2.0](v7.1.0...v7.2.0) (2020-07-28)

### Features

* add FileHeader.getFileName ([b6da583](b6da583)), closes [#34](#34) [#53](#53)
@gotson
Copy link
Member

gotson commented Jul 28, 2020

🎉 This issue has been resolved in version 7.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants