cache: actually fix script assembly encoding
This commit is contained in:
@@ -26,9 +26,10 @@ package net.runelite.cache.io;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.nio.Buffer;
|
import java.nio.Buffer;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.CharBuffer;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
public final class OutputStream extends java.io.OutputStream
|
public final class OutputStream extends java.io.OutputStream
|
||||||
{
|
{
|
||||||
@@ -57,7 +58,7 @@ public final class OutputStream extends java.io.OutputStream
|
|||||||
int newCapacity = buffer.capacity() * 2;
|
int newCapacity = buffer.capacity() * 2;
|
||||||
|
|
||||||
ByteBuffer old = buffer;
|
ByteBuffer old = buffer;
|
||||||
((Buffer) old).flip();
|
old.flip();
|
||||||
|
|
||||||
buffer = ByteBuffer.allocate(newCapacity);
|
buffer = ByteBuffer.allocate(newCapacity);
|
||||||
|
|
||||||
@@ -182,16 +183,17 @@ public final class OutputStream extends java.io.OutputStream
|
|||||||
|
|
||||||
public void writeString(String str)
|
public void writeString(String str)
|
||||||
{
|
{
|
||||||
byte[] b;
|
Charset utf8charset = Charset.forName("UTF-8");
|
||||||
try
|
Charset cp1252charset = Charset.forName("Cp1252");
|
||||||
{
|
|
||||||
b = str.getBytes("ISO-8859-1");
|
ByteBuffer inputBuffer = ByteBuffer.wrap(str.getBytes());
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException ex)
|
CharBuffer data = utf8charset.decode(inputBuffer);
|
||||||
{
|
|
||||||
throw new RuntimeException(ex);
|
ByteBuffer outputBuffer = cp1252charset.encode(data);
|
||||||
}
|
byte[] outputData = outputBuffer.array();
|
||||||
writeBytes(b);
|
|
||||||
|
writeBytes(outputData);
|
||||||
writeByte(0);
|
writeByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user