summaryrefslogtreecommitdiff
path: root/src/libexif/exif-utils.c
diff options
context:
space:
mode:
authorscuri <scuri>2009-08-20 12:13:11 +0000
committerscuri <scuri>2009-08-20 12:13:11 +0000
commit35733b87eed86e5228f12fa10c98a3d9d22a6073 (patch)
treeaa7e3c89788c15b925eecdbdf7e9d98291b4f469 /src/libexif/exif-utils.c
parent83b3c8b629d96f5fdf754d35d5f4f5369dbfef1d (diff)
*** empty log message ***
Diffstat (limited to 'src/libexif/exif-utils.c')
-rw-r--r--src/libexif/exif-utils.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/libexif/exif-utils.c b/src/libexif/exif-utils.c
index 9386012..a6e7696 100644
--- a/src/libexif/exif-utils.c
+++ b/src/libexif/exif-utils.c
@@ -1,6 +1,6 @@
/* exif-utils.c
*
- * Copyright © 2001 Lutz Müller <lutz@users.sourceforge.net>
+ * Copyright (c) 2001 Lutz Mueller <lutz@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -212,3 +212,40 @@ exif_set_srational (unsigned char *buf, ExifByteOrder order,
exif_set_slong (buf, order, value.numerator);
exif_set_slong (buf + 4, order, value.denominator);
}
+
+void
+exif_convert_utf16_to_utf8 (char *out, const unsigned short *in, int maxlen)
+{
+ /* This function converts rather UCS2 than UTF16 to UTF8 */
+ if (maxlen <= 0) {
+ return;
+ }
+ while (*in) {
+ if (*in < 0x80) {
+ if (maxlen > 1) {
+ *out++ = (char)*in++;
+ maxlen--;
+ } else {
+ break;
+ }
+ } else if (*in < 0x800) {
+ if (maxlen > 2) {
+ *out++ = ((*in >> 6) & 0x1F) | 0xC0;
+ *out++ = (*in++ & 0x3F) | 0x80;
+ maxlen -= 2;
+ } else {
+ break;
+ }
+ } else {
+ if (maxlen > 2) {
+ *out++ = ((*in >> 12) & 0x0F) | 0xE0;
+ *out++ = ((*in >> 6) & 0x3F) | 0x80;
+ *out++ = (*in++ & 0x3F) | 0x80;
+ maxlen -= 3;
+ } else {
+ break;
+ }
+ }
+ }
+ *out = 0;
+}