0

How add cyrillic symbol in exif file? My code alwais added symbol "?". This code:

String userComment = "АБВГДЕЁЖЗИЙКЛСНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
exifInterface.setAttribute("UserComment", userComment );
exifInterface.saveAttributes();

or

String userComment = "АБВГДЕЁЖЗИЙКЛСНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
exifInterface.setAttribute("UserComment", new String(userComment.getBytes(), "UTF-8"));
exifInterface.saveAttributes();
user1854307
  • 580
  • 4
  • 8
  • 21

2 Answers2

0

Think that ExifInterface class does not support this cyrillic.

I tried to get the bytes from that tag with

    byte [] bytes1 = exifInterface.getAttribute("UserComment").getBytes();
    byte [] bytes2 = exifInterface.getAttribute("UserComment").getBytes("utf-8");
//  byte [] bytes3 = exifInterface.getAttribute("UserComment").getBytes("utf-16");
//  byte [] bytes3 = exifInterface.getAttribute("UserComment").getBytes("ISO-8859-1");
    byte [] bytes3 = exifInterface.getAttribute("UserComment").getBytes("windows-1252");

And then displayed the bytes in hexadecimal notation. They were all rubbish.

There were 66 bytes for your 33 characters. Dont know which encoding is used.

I wanted to compare them with the bytes of your alphabet string.

Also tried compiling for Andoid 7 but all the same.

I give up ;-).

greenapps
  • 11,154
  • 2
  • 16
  • 19
0

"UserComment" tag in Exif support ASCII or Unicode.

Unfortunately, Android's ExifInterface only use ASCII to write or read the tag.

So, cyrillic symbol is not support by Android's ExifInterface.

But this lib may help you:

https://github.com/ddyos/UnicodeExifInterface

chan
  • 71
  • 1
  • 5