mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 04:25:29 -04:00
#492: Now correctly parses multiple strings for ASCII fields.
(cherry picked from commit 8247861095c5980ca3dbc278fd775ce6fc4de070)
This commit is contained in:
parent
0e41d4a5f7
commit
bdd7f5b228
@ -395,10 +395,16 @@ public final class TIFFReader extends MetadataReader {
|
|||||||
if (pCount == 0) {
|
if (pCount == 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: This can actually be more than one string, each string ends with a NULL-terminator
|
||||||
byte[] ascii = new byte[pCount];
|
byte[] ascii = new byte[pCount];
|
||||||
pInput.readFully(ascii);
|
pInput.readFully(ascii);
|
||||||
int len = ascii[ascii.length - 1] == 0 ? ascii.length - 1 : ascii.length;
|
int len = ascii[ascii.length - 1] == 0 ? ascii.length - 1 : ascii.length;
|
||||||
return StringUtil.decode(ascii, 0, len, "UTF-8"); // UTF-8 is ASCII compatible
|
|
||||||
|
String[] strings = new String(ascii, 0, len, StandardCharsets.UTF_8) // UTF-8 is ASCII compatible
|
||||||
|
.split("\0"); // Split on NULL
|
||||||
|
|
||||||
|
return strings.length == 1 ? strings[0] : strings;
|
||||||
case TIFF.TYPE_BYTE:
|
case TIFF.TYPE_BYTE:
|
||||||
if (pCount == 1) {
|
if (pCount == 1) {
|
||||||
return pInput.readUnsignedByte();
|
return pInput.readUnsignedByte();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user