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 Unicode character in file path #442

Open
Aliang-code opened this issue Oct 7, 2024 · 0 comments
Open

Support Unicode character in file path #442

Aliang-code opened this issue Oct 7, 2024 · 0 comments

Comments

@Aliang-code
Copy link

when I have some Unicode character in my image path(.e.g D:\相册\LR\相册\佳能\103___04\IMG_0661.jpg)
and then enable stayOpen flag, it always return "File not Found".
I have checked issuse at forum, got this : https://www.photools.com/community/index.php?topic=10740.0

The key part is
-charset
filename=UTF8
which tells ExifTool that the file name is in UTF-8 encoding.
German umlauts, Chinese, Russian or other non-ASCII characters no problem.

So i extend StandardOptions (unfortunately it was final class), like this:

public class SupportUtf8FileNameOptions implements ExifToolOptions {
    private StandardOptions standardOptions;

    public SupportUtf8FileNameOptions(StandardOptions standardOptions) {
        this.standardOptions = standardOptions;
    }

    @Override
    public Iterable<String> serialize() {
        List<String> arguments = (List<String>) standardOptions.serialize();
        arguments.add("-charset");
        arguments.add("filename=UTF8");
        return arguments;
    }
}

now it running well for unicode character path

exifTool.getImageMeta(new File("D:\\相册\\LR\\相册\\佳能\\103___04\\IMG_0661.jpg"),
                new SupportUtf8FileNameOptions(StandardOptions.builder().withFormat(StandardFormat.NUMERIC).build()),
                StandardTags.values());

Therefore, hope that StandardOptions.Builder().withCharset can support custom content, just change the parameter type to String

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

No branches or pull requests

1 participant