mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Cleanup
This commit is contained in:
parent
5e3b817b81
commit
101b712267
2 changed files with 5 additions and 7 deletions
|
|
@ -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 {
|
||||||
*/
|
*/
|
||||||
@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 {
|
||||||
* @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:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue