mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 03:40:54 +00:00
Added #116 Show invalid utf-8 bytes in Strings as {invalid_utf8:xxx}
This commit is contained in:
@@ -508,7 +508,10 @@ public class SWFInputStream implements AutoCloseable {
|
||||
r = readEx();
|
||||
if (r == 0) {
|
||||
endDumpLevel();
|
||||
return new String(baos.toByteArray(), swf == null ? Utf8Helper.charsetName : swf.getCharset());
|
||||
if (swf == null || "UTF-8".equals(swf.getCharset())) {
|
||||
return Utf8Helper.decode(baos.toByteArray());
|
||||
}
|
||||
return new String(baos.toByteArray(), swf.getCharset());
|
||||
}
|
||||
baos.write(r);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
|
||||
import com.jpexs.helpers.ByteArrayRange;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -179,7 +180,12 @@ public class SWFOutputStream extends OutputStream {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeString(String value) throws IOException {
|
||||
byte[] data = value.getBytes(charset);
|
||||
byte[] data;
|
||||
if ("UTF-8".equals(charset)) {
|
||||
data = Utf8Helper.getBytes(value);
|
||||
} else {
|
||||
data = value.getBytes(charset);
|
||||
}
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
if (data[i] == 0) {
|
||||
throw new IOException("String should not contain null character.");
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfo;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfoSpecial;
|
||||
import com.jpexs.decompiler.flash.dumpview.DumpInfoSpecialType;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.MemoryInputStream;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -523,8 +524,8 @@ public class ABCInputStream implements AutoCloseable {
|
||||
stringDataBuffer = new byte[newLength];
|
||||
}
|
||||
|
||||
safeRead(length, stringDataBuffer);
|
||||
String r = new String(stringDataBuffer, 0, length, Utf8Helper.charset);
|
||||
safeRead(length, stringDataBuffer);
|
||||
String r = Utf8Helper.decode(stringDataBuffer, 0, length);
|
||||
endDumpLevel(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user