我使用GTKmm和exiv2从照片中读取EXIF元数据。但是,Exiv2函数只接受std::string文件路径...当我在非ASCII文件路径上尝试它时,它会使程序崩溃。
有没有办法读取这些数据?如果Exiv2能接受Glib::ustring就太好了……
我对Windows和Linux的解决方案感兴趣。
发布于 2011-11-04 23:13:22
好了,我有一个解决方案!
您只需要使用函数Glibmm::locale_from_utf8将UTF8字符串转换为标准(Ascii)字符串。下面是一个示例:
void get_exif_data(const Glib::ustring &image_src)
{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(Glib::locale_from_utf8(image_src));
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
Exiv2::ExifData::const_iterator it = exifData.begin();
for(it;it!=exifData.end();it++) cout << it->key() + ": " + it->getValue() << endl;
}发布于 2011-11-03 01:11:11
如果这是在Windows中,那么你可以使用GetShortPathName。
干杯&哈。
https://stackoverflow.com/questions/7984205
复制相似问题