Writing both newline and letters ÅÄÖ to XPComment

Started by ingolfdahl, November 15, 2018, 02:50:09 PM

Previous topic - Next topic

ingolfdahl

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

StarGeek

See FAQ #18
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.  Using your example:
exiftool -E -XPComment=" Härnösandståget åker över Åtvidaberg "
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

ingolfdahl

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.

Phil Harvey

... but there definitely is something weird going on if you mix HTML entities with other encoded characters.  I'll look into this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

#4
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.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).