in src/main/java/com/univocity/parsers/common/input/BomInput.java [51:91]
public BomInput(InputStream input) {
this.input = input;
try { //This looks shitty on purpose (all in the name of speed).
if ((bytes[0] = next()) == 0xEF) {
if ((bytes[1] = next()) == 0xBB) {
if ((bytes[2] = next()) == 0xBF) {
setEncoding("UTF-8");
}
}
} else if (bytes[0] == 0xFE) {
if ((bytes[1] = next()) == 0xFF) {
setEncoding("UTF-16BE");
}
} else if (bytes[0] == 0xFF) {
if ((bytes[1] = next()) == 0xFE) {
if ((bytes[2] = next()) == 0x00) {
if ((bytes[3] = next()) == 0x00) {
setEncoding("UTF-32LE");
} else {
setEncoding("UTF-16LE"); //gotcha!
}
} else {
setEncoding("UTF-16LE"); //gotcha!
}
}
} else if (bytes[0] == 0x00) {
if ((bytes[1] = next()) == 0x00) {
if ((bytes[2] = next()) == 0xFE) {
if ((bytes[3] = next()) == 0xFF) {
setEncoding("UTF-32BE");
}
}
}
}
} catch (IOException e) {
// store the exception for later. We want the wrapper to behave exactly like the original input stream and
// might need to return any bytes read before this blew up.
exception = e;
}
}