Skip to content

Support Unicode character in file path #442

@Aliang-code

Description

@Aliang-code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions