ICUBinary.java
2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.agl.impl;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
public final class ICUBinary {
public static final byte[] readHeader(InputStream inputStream, byte[] dataFormatIDExpected, Authenticate authenticate) throws IOException {
DataInputStream input = new DataInputStream(inputStream);
char headersize = input.readChar();
char readcount = '\u0002';
byte magic1 = input.readByte();
++readcount;
byte magic2 = input.readByte();
++readcount;
if (magic1 != -38 || magic2 != 39) {
throw new IOException("ICU data file error: Not an ICU data file");
}
input.readChar();
readcount += 2;
input.readChar();
readcount += 2;
byte bigendian = input.readByte();
++readcount;
byte charset = input.readByte();
++readcount;
byte charsize = input.readByte();
++readcount;
input.readByte();
++readcount;
byte[] dataFormatID = new byte[4];
input.readFully(dataFormatID);
readcount += 4;
byte[] dataVersion = new byte[4];
input.readFully(dataVersion);
readcount += 4;
byte[] unicodeVersion = new byte[4];
input.readFully(unicodeVersion);
if (headersize < (readcount += 4)) {
throw new IOException("Internal Error: Header size error");
}
input.skipBytes(headersize - readcount);
if (bigendian != 1 || charset != 0 || charsize != 2 || !Arrays.equals(dataFormatIDExpected, dataFormatID) || authenticate != null && !authenticate.isDataVersionAcceptable(dataVersion)) {
throw new IOException("ICU data file error: Header authentication failed, please check if you have a valid ICU data file");
}
return unicodeVersion;
}
public static interface Authenticate {
public boolean isDataVersionAcceptable(byte[] var1);
}
}