While writing a custom batch application for a client to update standard EXIF tags for photos based on directory names I came across a particular challenge.
He asked if I could update the XPKeywords, XPAuthor, and XPTitle tags so that if someone downloaded one of his photos, right clicked on it, and chose Properties->Details the tags would display.
Since they are listed in the Exiv2 standard tags list I thought it would be a piece of cake. However it turns out that Windows doesn’t want a text string, it wants it in a byte array encoded in UCS2 (which I’ve never heard of before). Google/Github wasn’t much help, but I did find one reference to it, and through trial and error I came up with the following code which gets the job done. I’m not sure if this is the right way to do it, or the most efficient, but it works.
Basically, it wants a string comprised of the ascii value of each letter, separated by a zero, with three zeros at the end. Here is the C++ snippet that I’m using:
Note: the above code uses the fmt C++ string formatting library. Even though I’m using c++20, since I’m cross compiling for some reason the new c++20 format library wasn’t available.
Logo by Pixel Perfect / Flat Icon