#571: Add Iptc.Envelope.CharacterSet only if any other dataset is added, fixed tests.

This commit is contained in:
Andreas Huggel 2009-12-28 12:24:14 +00:00
parent c3477b203a
commit eca690a2fb
3 changed files with 19 additions and 9 deletions

View File

@ -1119,13 +1119,14 @@ namespace Exiv2 {
#endif
return;
}
// Todo: Escape non-ASCII characters in XMP text values
(*iptcData_)[to] = value;
(*iptcData_)["Iptc.Envelope.CharacterSet"] = "\033%G"; // indicate UTF-8 encoding
if (erase_) xmpData_->erase(pos);
return;
}
int count = pos->count();
bool added = false;
for (int i = 0; i < count; ++i) {
std::string value = pos->toString(i);
if (!pos->value().ok()) {
@ -1134,12 +1135,13 @@ namespace Exiv2 {
#endif
continue;
}
// Todo: Escape non-ASCII characters in XMP text values
IptcKey key(to);
Iptcdatum id(key);
id.setValue(value);
iptcData_->add(id);
added = true;
}
if (added) (*iptcData_)["Iptc.Envelope.CharacterSet"] = "\033%G"; // indicate UTF-8 encoding
if (erase_) xmpData_->erase(pos);
}
@ -1304,7 +1306,6 @@ namespace Exiv2 {
{
Converter converter(iptcData, const_cast<XmpData&>(xmpData));
converter.cnvFromXmp();
iptcData["Iptc.Envelope.CharacterSet"] = "\033%G"; // indicate UTF-8 encoding
}
void moveXmpToIptc(XmpData& xmpData, IptcData& iptcData)
@ -1312,7 +1313,6 @@ namespace Exiv2 {
Converter converter(iptcData, const_cast<XmpData&>(xmpData));
converter.setErase();
converter.cnvFromXmp();
iptcData["Iptc.Envelope.CharacterSet"] = "\033%G"; // indicate UTF-8 encoding
}
} // namespace Exiv2

View File

@ -158,7 +158,7 @@ echo
echo Testcase 12
echo ===========
\cp $IMG s.jpg
$exiv2 -M'set Iptc.Application2.LocationName Kuala Lumpur' s.jpg
$exiv2 -M'set Iptc.Application2.SubLocation Kuala Lumpur' s.jpg
$exiv2 -pi s.jpg
rm -f s.xmp
$exiv2 -eX s.jpg
@ -217,7 +217,7 @@ $exiv2 -pi v.jpg
# ----------------------------------------------------------------------
# Evaluate results
cat $results | tr -d '\r' > $results-stripped
cat $results | sed 's/\x0d$//' > $results-stripped
diff -q $results-stripped $good
rc=$?
if [ $rc -eq 0 ] ; then

View File

@ -3,18 +3,21 @@ Testcase 1
Xmp.dc.description LangAlt 1 lang="x-default" The Exif image description
Exif.Image.ImageDescription Ascii 27 The Exif image description
Iptc.Application2.Caption String 26 The Exif image description
Iptc.Envelope.CharacterSet String 3 %G
Testcase 2
==========
Xmp.dc.description LangAlt 1 lang="x-default" The Exif image description
Exif.Image.ImageDescription Ascii 27 The Exif image description
Iptc.Application2.Caption String 26 The Exif image description
Iptc.Envelope.CharacterSet String 3 %G
Testcase 3
==========
Xmp.dc.description LangAlt 1 lang="de-DE" The Exif image description
Exif.Image.ImageDescription Ascii 27 The Exif image description
Iptc.Application2.Caption String 26 The Exif image description
Iptc.Envelope.CharacterSet String 3 %G
Testcase 4
==========
@ -34,6 +37,7 @@ Warning: Failed to convert Xmp.dc.description to Exif.Image.ImageDescription
Xmp.dc.description LangAlt 3 lang="x-default" How to fix this mess, lang="de-DE" The Exif image description, lang="it-IT" Ciao bella
Exif.Image.ImageDescription Ascii 21 How to fix this mess
Iptc.Application2.Caption String 20 How to fix this mess
Iptc.Envelope.CharacterSet String 3 %G
Testcase 6
==========
@ -63,6 +67,7 @@ o.xmp: No Exif data found in the file
Iptc.Application2.Keywords String 3 Sex
Iptc.Application2.Keywords String 5 Drugs
Iptc.Application2.Keywords String 11 Rock'n'roll
Iptc.Envelope.CharacterSet String 3 %G
Testcase 9
==========
@ -72,6 +77,7 @@ p.jpg: No Exif data found in the file
Iptc.Application2.Keywords String 3 Sex
Iptc.Application2.Keywords String 5 Drugs
Iptc.Application2.Keywords String 11 Rock'n'roll
Iptc.Envelope.CharacterSet String 3 %G
Testcase 10
===========
@ -90,18 +96,20 @@ r.jpg: No IPTC data found in the file
Testcase 12
===========
Iptc.Application2.LocationName String 12 Kuala Lumpur
Iptc.Application2.SubLocation String 12 Kuala Lumpur
Xmp.iptc.Location XmpText 12 Kuala Lumpur
File 1/1: s.xmp
s.xmp: No Exif data found in the file
Iptc.Application2.LocationName String 12 Kuala Lumpur
Iptc.Application2.SubLocation String 12 Kuala Lumpur
Iptc.Envelope.CharacterSet String 3 %G
Testcase 13
===========
Xmp.iptc.Location XmpText 12 Kuala Lumpur
File 1/1: t.jpg
t.jpg: No Exif data found in the file
Iptc.Application2.LocationName String 12 Kuala Lumpur
Iptc.Application2.SubLocation String 12 Kuala Lumpur
Iptc.Envelope.CharacterSet String 3 %G
Testcase 14
===========
@ -141,6 +149,7 @@ Exif.GPSInfo.GPSLatitudeRef Ascii 2 N
Exif.GPSInfo.GPSTimeStamp Rational 3 1/1 2/1 999999999/1000000000
Exif.GPSInfo.GPSDateStamp Ascii 11 2003:12:14
Iptc.Application2.DateCreated Date 8 2007-05-09
Iptc.Envelope.CharacterSet String 3 %G
Testcase 15
===========
@ -172,3 +181,4 @@ Exif.GPSInfo.GPSLatitude Rational 3 3/1 8/1 1858407/6250
Exif.GPSInfo.GPSTimeStamp Rational 3 1/1 2/1 999999999/1000000000
Exif.GPSInfo.GPSDateStamp Ascii 11 2003:12:14
Iptc.Application2.DateCreated Date 8 2007-05-09
Iptc.Envelope.CharacterSet String 3 %G