47 lines
1.4 KiB
Java
47 lines
1.4 KiB
Java
package lombok.delombok;
|
|
|
|
import java.io.IOException;
|
|
import java.io.Writer;
|
|
import java.nio.charset.Charset;
|
|
import java.nio.charset.CharsetEncoder;
|
|
/* loaded from: com.discord-119010.apk:lombok/delombok/UnicodeEscapeWriter.SCL.lombok */
|
|
public class UnicodeEscapeWriter extends Writer {
|
|
private final Writer writer;
|
|
private CharsetEncoder encoder;
|
|
|
|
public UnicodeEscapeWriter(Writer writer, Charset charset) {
|
|
this.writer = writer;
|
|
this.encoder = charset.newEncoder();
|
|
}
|
|
|
|
@Override // java.io.Writer, java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() throws IOException {
|
|
this.writer.close();
|
|
}
|
|
|
|
@Override // java.io.Writer, java.io.Flushable
|
|
public void flush() throws IOException {
|
|
this.writer.flush();
|
|
}
|
|
|
|
@Override // java.io.Writer
|
|
public final void write(char[] cArr, int i, int i2) throws IOException {
|
|
int i3 = i;
|
|
int i4 = i + i2;
|
|
for (int i5 = i3; i5 < i4; i5++) {
|
|
if (!this.encoder.canEncode(cArr[i5])) {
|
|
this.writer.write(cArr, i3, i5 - i3);
|
|
writeUnicodeEscape(cArr[i5]);
|
|
i3 = i5 + 1;
|
|
}
|
|
}
|
|
if (i3 < i4) {
|
|
this.writer.write(cArr, i3, i4 - i3);
|
|
}
|
|
}
|
|
|
|
protected void writeUnicodeEscape(char c) throws IOException {
|
|
this.writer.write(String.format("\\u%04x", Integer.valueOf(c)));
|
|
}
|
|
}
|