mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 20:15:28 -04:00
#492: Now correctly parses multiple strings for ASCII fields.
This commit is contained in:
parent
8480c929c1
commit
8247861095
@ -395,10 +395,16 @@ public final class TIFFReader extends MetadataReader {
|
||||
if (pCount == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// NOTE: This can actually be more than one string, each string ends with a NULL-terminator
|
||||
byte[] ascii = new byte[pCount];
|
||||
pInput.readFully(ascii);
|
||||
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:
|
||||
if (pCount == 1) {
|
||||
return pInput.readUnsignedByte();
|
||||
|
Loading…
x
Reference in New Issue
Block a user