diff options
author | Earl Ou <shunhsingou@google.com> | 2012-10-18 19:14:16 +0800 |
---|---|---|
committer | Earl Ou <shunhsingou@google.com> | 2012-10-31 10:14:06 +0800 |
commit | ccbd3f8a8c0e8caec948f56afd870fdce1c19bf8 (patch) | |
tree | c8ec87067ec9c6a82f40e6dbeaa048ce2a770471 /gallerycommon | |
parent | e7fab41c07189f55da7435542993e3276f4624b7 (diff) | |
download | android_packages_apps_Gallery2-ccbd3f8a8c0e8caec948f56afd870fdce1c19bf8.tar.gz android_packages_apps_Gallery2-ccbd3f8a8c0e8caec948f56afd870fdce1c19bf8.tar.bz2 android_packages_apps_Gallery2-ccbd3f8a8c0e8caec948f56afd870fdce1c19bf8.zip |
Do not use UTF-8 to decode string in ExifOutputStream
Change-Id: Id0303a9e8a72db1625e8d0f7487be44227b0ce6a
Diffstat (limited to 'gallerycommon')
-rw-r--r-- | gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java index b8db8e34c..e5e776098 100644 --- a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java +++ b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.nio.charset.Charset; public class ExifOutputStream extends FilterOutputStream { private static final String TAG = "ExifOutputStream"; @@ -215,9 +216,12 @@ public class ExifOutputStream extends FilterOutputStream { throws IOException { switch (tag.getDataType()) { case ExifTag.TYPE_ASCII: - dataOutputStream.write(tag.getString().getBytes()); - int remain = tag.getComponentCount() - tag.getString().length(); - for (int i = 0; i < remain; i++) { + byte buf[] = tag.getString().getBytes(Charset.forName("US-ASCII")); + if (buf.length == tag.getComponentCount()) { + buf[buf.length - 1] = 0; + dataOutputStream.write(buf); + } else { + dataOutputStream.write(buf); dataOutputStream.write(0); } break; @@ -234,7 +238,7 @@ public class ExifOutputStream extends FilterOutputStream { break; case ExifTag.TYPE_UNDEFINED: case ExifTag.TYPE_UNSIGNED_BYTE: - byte[] buf = new byte[tag.getComponentCount()]; + buf = new byte[tag.getComponentCount()]; tag.getBytes(buf); dataOutputStream.write(buf); break; |