Added Setting charset in commandline (-charset XXX)

Default charset for SWF files version <= 5 is system charset
This commit is contained in:
Jindra Petřík
2022-11-11 09:58:13 +01:00
parent 3c3a8545a5
commit e3ed5bd4a5
6 changed files with 176 additions and 132 deletions

View File

@@ -936,11 +936,13 @@ public final class SWF implements SWFContainerItem, Timelined {
* @throws IOException
*/
public void saveTo(OutputStream os) throws IOException {
checkCharset();
byte[] uncompressedData = saveToByteArray();
compress(new ByteArrayInputStream(uncompressedData), os, compression, lzmaProperties);
}
public void saveTo(OutputStream os, boolean gfx) throws IOException {
checkCharset();
byte[] uncompressedData = saveToByteArray(gfx);
compress(new ByteArrayInputStream(uncompressedData), os, compression, lzmaProperties);
}
@@ -980,6 +982,12 @@ public final class SWF implements SWFContainerItem, Timelined {
private byte[] saveToByteArray() throws IOException {
return saveToByteArray(gfx);
}
private void checkCharset() {
if (version > 5) {
charset = Utf8Helper.charsetName;
}
}
private byte[] saveToByteArray(boolean gfx) throws IOException {
byte[] data;