This commit is contained in:
Lev 2022-11-26 03:04:35 +03:00
parent 5e3b817b81
commit 101b712267
2 changed files with 5 additions and 7 deletions

View file

@ -234,7 +234,7 @@ public final class ParsableByteArray {
/** Peeks at the next char. */
public char peekLittleEndianChar() {
return (char) ((data[position] & 0xFF) | (data[position + 1] & 0xFF) << 8 );
return (char) ((data[position] & 0xFF) | (data[position + 1] & 0xFF) << 8);
}
/** Reads the next byte as an unsigned value. */
@ -554,12 +554,12 @@ public final class ParsableByteArray {
*/
@Nullable
public String readUtfLine(Charset charset) {
if(!charset.equals(Charsets.UTF_8)
if (!charset.equals(Charsets.UTF_8)
&& !charset.equals(Charsets.UTF_16BE)
&& !charset.equals(Charsets.UTF_16LE)) {
throw new IllegalArgumentException("Only UTF-8, UTF-16LE, UTF-16BE encoding supported.");
}
if(charset.equals(Charsets.UTF_8)) {
if (charset.equals(Charsets.UTF_8)) {
return readLine();
}

View file

@ -149,13 +149,11 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
* @return determined encoding
*/
private Charset detectUtfCharset(ParsableByteArray data) {
if(data.limit() < 2) {
if (data.limit() < 2) {
return Charsets.UTF_8;
}
char twoBytes = data.peekChar();
switch (twoBytes) {
switch (data.peekChar()) {
case ParsableByteArray.BOM_UTF16_BE:
return Charsets.UTF_16BE;
case ParsableByteArray.BOM_UTF16_LE: