Search code examples
c#windowsvb.netexif

Correctly decode accented chars in XPKeywords from image EXIF data in Windows app using C# or VB.NET


I am facing an encoding issue I can't seem to solve since I'm no real encoding expert...

I am entering XPKeywords information in some of my numerous images in Windows so that I could sort them out later on using these keywords.

I did a test on one of the images, adding some French accented chars such as é, è, à etc...

Adding a keyword containing 'é' for instance displays ok in my French Windows Explorer. However accessing the tag using C#/VB displays "�". I tried all sorts of conversions, googled for XPKeywords and found that XPKeywords seems encoded in UCS-2 but can't still find any way to correctly decode this field so that I can display correct info.

Probably easy but cannot figure it out. Any hint would be greatly appreciated.

Thx


Solution

  • Got this to work. Encoding value used within the GetString function was defined as UTF-8. Changing it to Unicode did the trick. Thanks to all for the heads up!