EXIF GetString and foreign characters

M

mikfrost

I'm trying to read the exif info in a JPG image file. Reading the
ImageDescription field (270) that contains "abcæåø" only reads the
first 3 characters "abc". The field was written with ACDSee photo
manager.

// using the GetString method

propItem = img.GetPropertyItem(270);
img_desc = Encoding.UTF8.GetString(propItem.Value);

// result : img_desc = "abc"

// BitConverter reads the correct acsii values!!

acsii_values = BitConverter.ToString(propItem.Value);

// result : acsii_values = "61-62-63-E6-E5-F8-00"

Why does GetString not get the foreign charaters "E6-E5-F8"?
 
M

mikfrost

I'm trying to read the exif info in a JPG image file. Reading the
ImageDescription field (270) that contains "abcæåø" only reads the
first 3 characters "abc". The field was written with ACDSee photo
manager.

// using the GetString method

propItem = img.GetPropertyItem(270);
img_desc = Encoding.UTF8.GetString(propItem.Value);

// result : img_desc = "abc"

// BitConverter reads the correct acsii values!!

acsii_values = BitConverter.ToString(propItem.Value);

// result : acsii_values = "61-62-63-E6-E5-F8-00"

Why does GetString not get the foreign charaters "E6-E5-F8"?

The field was written in iso8859-1. This fixed the problem:

Encoding iso = Encoding.GetEncoding("iso8859-1");
img_desc = iso.GetString(propItem.Value);

I guess there is no method to detect which encoding is used in the
EXIF field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top