Commit 101b7122 by Lev

Cleanup

parent 5e3b817b
...@@ -234,7 +234,7 @@ public final class ParsableByteArray { ...@@ -234,7 +234,7 @@ public final class ParsableByteArray {
/** Peeks at the next char. */ /** Peeks at the next char. */
public char peekLittleEndianChar() { 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. */ /** Reads the next byte as an unsigned value. */
...@@ -554,12 +554,12 @@ public final class ParsableByteArray { ...@@ -554,12 +554,12 @@ public final class ParsableByteArray {
*/ */
@Nullable @Nullable
public String readUtfLine(Charset charset) { 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_16BE)
&& !charset.equals(Charsets.UTF_16LE)) { && !charset.equals(Charsets.UTF_16LE)) {
throw new IllegalArgumentException("Only UTF-8, UTF-16LE, UTF-16BE encoding supported."); 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(); return readLine();
} }
......
...@@ -149,13 +149,11 @@ public final class SubripDecoder extends SimpleSubtitleDecoder { ...@@ -149,13 +149,11 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
* @return determined encoding * @return determined encoding
*/ */
private Charset detectUtfCharset(ParsableByteArray data) { private Charset detectUtfCharset(ParsableByteArray data) {
if(data.limit() < 2) { if (data.limit() < 2) {
return Charsets.UTF_8; return Charsets.UTF_8;
} }
char twoBytes = data.peekChar(); switch (data.peekChar()) {
switch (twoBytes) {
case ParsableByteArray.BOM_UTF16_BE: case ParsableByteArray.BOM_UTF16_BE:
return Charsets.UTF_16BE; return Charsets.UTF_16BE;
case ParsableByteArray.BOM_UTF16_LE: case ParsableByteArray.BOM_UTF16_LE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment