I am trying to write both newline characters and letters of the type ÅÄÖåäö to the tag XPComment. I write commands to cmd.exe under Windows. (In practice, I use Mathematica for this task.) I can write to the Comment tag by
[exiftool -L -E -Comment=" Härnösandståget åker över Åtvidaberg " "D:\path\Åtvidaberg.jpg"]
but if I do the same för XPComment, it fails if I have any of the letters ÅÄÖåäö in the string:
[exiftool -L -E -XPComment=" Härnösandståget åker över Åtvidaberg " "D:\path\Åtvidaberg.jpg"]
The following works:
[exiftool -L -XPComment=" Härnösandståget åker över Åtvidaberg " "D:\path\Åtvidaberg.jpg"]
but then I cannot use "
" as newline characters. I have not been able to use the -@ option either together with the letters ÅÄÖåäö. I can, however, go around the problem by writing the text to a file, and reading from that.
To me, this looks like a bug.
I am using exiftool version 11.16
See FAQ #18 (https://exiftool.org/faq.html#Q18)
tl;dr Windows command line support of alternate character sets sucks.
Try what's listed in FAQ 18. You can also try searching the forum for "faq 18" and "Unicode" to see what worked for others.
Myself, I've never been able to get such characters to work and tend to convert them to html entities and use the -E (escapeHTML) option (https://exiftool.org/exiftool_pod.html#E--ex--escapeHTML--escapeXML). Using your example:
exiftool -E -XPComment=" Härnösandståget åker över Åtvidaberg "
Thanks, I tried that solution with HTML codes before but did not get it to work, I had probably made some mistake. Now it seems to work, so I will implement that.
... but there definitely is something weird going on if you mix HTML entities with other encoded characters. I'll look into this.
- Phil
OK, it's not as weird as I thought. ExifTool can currently only apply HTML escaping to a UTF-8 encoded string. So when you use -E, ExifTool assumes UTF-8 encoding and the -L option has no effect. I should document this.
- Phil
Edit: Actually, I think I should just remove this restriction and allow HTML encodings other than just UTF-8. I'll see about implementing this for the next release.