[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:41:07 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=dab01e7
The following commit has been merged in the master branch:
commit dab01e73e9c2c5b9b78325cd3672cbf479652a1d
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Fri Jan 15 11:29:55 2010 +0000
#662: Added CommentValue::detectCharset and an optional parameter for the encoding to CommentValue::comment().
---
src/value.cpp | 28 ++++++++++++++++------------
src/value.hpp | 26 +++++++++++++++++++++++---
2 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/src/value.cpp b/src/value.cpp
index 81ae29d..d36ae8a 100644
--- a/src/value.cpp
+++ b/src/value.cpp
@@ -498,14 +498,14 @@ namespace Exiv2 {
std::string c = value_;
if (charsetId() == unicode) {
c = value_.substr(8);
- std::string::size_type l = c.size();
+ std::string::size_type sz = c.size();
if (byteOrder_ == littleEndian && byteOrder == bigEndian) {
convertStringCharset(c, "UCS-2LE", "UCS-2BE");
- assert(c.size() == l);
+ assert(c.size() == sz);
}
else if (byteOrder_ == bigEndian && byteOrder == littleEndian) {
convertStringCharset(c, "UCS-2BE", "UCS-2LE");
- assert(c.size() == l);
+ assert(c.size() == sz);
}
c = value_.substr(0, 8) + c;
}
@@ -523,19 +523,16 @@ namespace Exiv2 {
return os << comment();
}
- std::string CommentValue::comment() const
+ std::string CommentValue::comment(const char* encoding) const
{
+ std::string c;
if (value_.length() < 8) {
- return value_; // Todo: return "" ?
+ return c;
}
- std::string c = value_.substr(8);
+ c = value_.substr(8);
if (charsetId() == unicode) {
- if (byteOrder_ == littleEndian) {
- convertStringCharset(c, "UCS-2LE", "UTF-8");
- }
- else {
- convertStringCharset(c, "UCS-2BE", "UTF-8");
- }
+ const char* from = encoding == 0 ? detectCharset() : encoding;
+ convertStringCharset(c, from, "UTF-8");
}
return c;
}
@@ -550,6 +547,13 @@ namespace Exiv2 {
return charsetId;
}
+ const char* CommentValue::detectCharset() const
+ {
+ // Todo: Add logic to guess if the comment is encoded in UTF-8
+
+ return byteOrder_ == littleEndian ? "UCS-2LE" : "UCS-2BE";
+ }
+
CommentValue* CommentValue::clone_() const
{
return new CommentValue(*this);
diff --git a/src/value.hpp b/src/value.hpp
index 19af3c6..ab815ed 100644
--- a/src/value.hpp
+++ b/src/value.hpp
@@ -594,9 +594,29 @@ namespace Exiv2 {
read(const std::string& comment).
*/
std::ostream& write(std::ostream& os) const;
- //! Return the comment (without a charset="..." prefix)
- std::string comment() const;
- //! Return the charset id of the comment
+ /*!
+ @brief Return the comment (without a charset="..." prefix)
+
+ The comment is decoded to UTF-8. For Exif UNICODE comments, the
+ function makes an attempt to correctly determine the character
+ encoding of the value. Alternatively, the optional \em encoding
+ parameter can be used to specify it.
+
+ @param encoding Optional argument to specify the character encoding
+ that the comment is encoded in, as an iconv(3) name. Only used
+ for Exif UNICODE comments.
+
+ @return A string containing the comment converted to UTF-8.
+ */
+ std::string comment(const char* encoding =0) const;
+ /*!
+ @brief Determine the character encoding that was used to encode the
+ comment value as an iconv(3) name.
+
+ Todo: Implement rules
+ */
+ const char* detectCharset() const;
+ //! Return the Exif charset id of the comment
CharsetId charsetId() const;
//@}
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list