Take the 2-minute tour ×

I am using GTKmm and exiv2 to read EXIF metadata form photos. However Exiv2 functions accept only std::string file paths... When I try it on not ASCII filepath it crushes the program.

Is there any way to read that data? It would be great if Exiv2 accepted Glib::ustrings...

Edit: I'm interested in solutions for Windows and Linux.

share|improve this question
Please tag with appropriate OS. –  Cheers and hth. - Alf Nov 2 '11 at 17:13
Added info about OS. –  Marco Nov 2 '11 at 17:25
add comment

2 Answers

If this is in Windows then you can use GetShortPathName.

Cheers & hth.,

share|improve this answer
Note that this isn't guaranteed to work. Not all file systems support short path names, and on NTFS it's optional (i.e. can be turned off). –  MSalters Nov 3 '11 at 12:25
add comment
up vote 0 down vote accepted

Ok, I have a solution!

You just need to use function Glibmm::locale_from_utf8 to convert UTF8 string to std(ascii) string. Here is an example:

void get_exif_data(const Glib::ustring &image_src)
        Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(Glib::locale_from_utf8(image_src));
        Exiv2::ExifData &exifData = image->exifData();
        Exiv2::ExifData::const_iterator it = exifData.begin();
        for(it;it!=exifData.end();it++) cout << it->key() + ": " + it->getValue() << endl;

share|improve this answer
add comment

Your Answer


