|
22 | 22 | #include "XBDateTime.h"
|
23 | 23 | #include "Util.h"
|
24 | 24 | #include "utils/Variant.h"
|
| 25 | +#include "utils/CharsetConverter.h" |
25 | 26 |
|
26 | 27 | using namespace std;
|
27 | 28 |
|
@@ -64,7 +65,7 @@ void CPictureInfoTag::Archive(CArchive& ar)
|
64 | 65 | ar << CStdString(m_exifInfo.CameraMake);
|
65 | 66 | ar << CStdString(m_exifInfo.CameraModel);
|
66 | 67 | ar << m_exifInfo.CCDWidth;
|
67 |
| - ar << CStdString(m_exifInfo.Comments); |
| 68 | + ar << GetInfo(SLIDE_EXIF_COMMENT); // Store and restore the comment charset converted |
68 | 69 | ar << CStdString(m_exifInfo.Description);
|
69 | 70 | ar << CStdString(m_exifInfo.DateTime);
|
70 | 71 | for (int i = 0; i < 10; i++)
|
@@ -128,6 +129,7 @@ void CPictureInfoTag::Archive(CArchive& ar)
|
128 | 129 | GetStringFromArchive(ar, m_exifInfo.CameraModel, sizeof(m_exifInfo.CameraModel));
|
129 | 130 | ar >> m_exifInfo.CCDWidth;
|
130 | 131 | GetStringFromArchive(ar, m_exifInfo.Comments, sizeof(m_exifInfo.Comments));
|
| 132 | + m_exifInfo.CommentsCharset = EXIF_COMMENT_CHARSET_CONVERTED; // Store and restore the comment charset converted |
131 | 133 | GetStringFromArchive(ar, m_exifInfo.Description, sizeof(m_exifInfo.Description));
|
132 | 134 | GetStringFromArchive(ar, m_exifInfo.DateTime, sizeof(m_exifInfo.DateTime));
|
133 | 135 | for (int i = 0; i < 10; i++)
|
@@ -191,7 +193,7 @@ void CPictureInfoTag::Serialize(CVariant& value)
|
191 | 193 | value["cameramake"] = CStdString(m_exifInfo.CameraMake);
|
192 | 194 | value["cameramodel"] = CStdString(m_exifInfo.CameraModel);
|
193 | 195 | value["ccdwidth"] = m_exifInfo.CCDWidth;
|
194 |
| - value["comments"] = CStdString(m_exifInfo.Comments); |
| 196 | + value["comments"] = GetInfo(SLIDE_EXIF_COMMENT); // Charset conversion |
195 | 197 | value["description"] = CStdString(m_exifInfo.Description);
|
196 | 198 | value["datetime"] = CStdString(m_exifInfo.DateTime);
|
197 | 199 | for (int i = 0; i < 10; i++)
|
@@ -302,7 +304,20 @@ const CStdString CPictureInfoTag::GetInfo(int info) const
|
302 | 304 | break;
|
303 | 305 | case SLIDE_COMMENT:
|
304 | 306 | case SLIDE_EXIF_COMMENT:
|
305 |
| - value = m_exifInfo.Comments; |
| 307 | + // The charset used for the UserComment is stored in CommentsCharset: |
| 308 | + // Ascii, Unicode (UCS2), JIS (X208-1990), Unknown (application specific) |
| 309 | + if (m_exifInfo.CommentsCharset == EXIF_COMMENT_CHARSET_UNICODE) |
| 310 | + { |
| 311 | + g_charsetConverter.ucs2ToUTF8(CStdString16((uint16_t*)m_exifInfo.Comments), value); |
| 312 | + } |
| 313 | + else |
| 314 | + { |
| 315 | + // Ascii doesn't need to be converted (EXIF_COMMENT_CHARSET_ASCII) |
| 316 | + // Archived data is already converted (EXIF_COMMENT_CHARSET_CONVERTED) |
| 317 | + // Unknown data can't be converted as it could be any codec (EXIF_COMMENT_CHARSET_UNKNOWN) |
| 318 | + // JIS data can't be converted as CharsetConverter and iconv lacks support (EXIF_COMMENT_CHARSET_JIS) |
| 319 | + value = m_exifInfo.Comments; |
| 320 | + } |
306 | 321 | break;
|
307 | 322 | case SLIDE_EXIF_DATE_TIME:
|
308 | 323 | case SLIDE_EXIF_DATE:
|
|
0 commit comments