mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 14:10:46 +00:00
removed unnecessary string=>utf8 byte[]=>input stream=>reader converts, utf8 helper added (UnsupportedEndodingException should not thrown)
This commit is contained in:
@@ -103,6 +103,7 @@ import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.Cache;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.ProgressListener;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -111,7 +112,15 @@ import java.awt.Rectangle;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -316,7 +325,7 @@ public final class SWF {
|
||||
public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException {
|
||||
byte[] hdr = new byte[3];
|
||||
is.read(hdr);
|
||||
String shdr = new String(hdr, "utf-8");
|
||||
String shdr = new String(hdr, Utf8Helper.charset);
|
||||
if (!Arrays.asList(
|
||||
"FWS", //Uncompressed Flash
|
||||
"CWS", //ZLib compressed Flash
|
||||
@@ -479,7 +488,7 @@ public final class SWF {
|
||||
try {
|
||||
byte[] hdr = new byte[3];
|
||||
fis.read(hdr);
|
||||
String shdr = new String(hdr, "utf-8");
|
||||
String shdr = new String(hdr, Utf8Helper.charset);
|
||||
switch (shdr) {
|
||||
case "CWS":
|
||||
{
|
||||
@@ -487,7 +496,7 @@ public final class SWF {
|
||||
SWFInputStream sis = new SWFInputStream(fis, version, 4);
|
||||
long fileSize = sis.readUI32();
|
||||
SWFOutputStream sos = new SWFOutputStream(fos, version);
|
||||
sos.write("FWS".getBytes("utf-8"));
|
||||
sos.write(Utf8Helper.getBytes("FWS"));
|
||||
sos.writeUI8(version);
|
||||
sos.writeUI32(fileSize);
|
||||
InflaterInputStream iis = new InflaterInputStream(fis);
|
||||
@@ -519,7 +528,7 @@ public final class SWF {
|
||||
throw new IOException("LZMA:Error in data stream");
|
||||
}
|
||||
try (SWFOutputStream sos = new SWFOutputStream(fos, version)) {
|
||||
sos.write("FWS".getBytes("utf-8"));
|
||||
sos.write(Utf8Helper.getBytes("FWS"));
|
||||
sos.write(version);
|
||||
sos.writeUI32(fileSize);
|
||||
sos.write(baos.toByteArray());
|
||||
@@ -1052,20 +1061,20 @@ public final class SWF {
|
||||
writeLE(subChunk1Data, bitsPerSample, 2);
|
||||
|
||||
ByteArrayOutputStream chunks = new ByteArrayOutputStream();
|
||||
chunks.write("fmt ".getBytes("utf-8"));
|
||||
chunks.write(Utf8Helper.getBytes("fmt "));
|
||||
byte[] subChunk1DataBytes = subChunk1Data.toByteArray();
|
||||
writeLE(chunks, subChunk1DataBytes.length, 4);
|
||||
chunks.write(subChunk1DataBytes);
|
||||
|
||||
|
||||
chunks.write("data".getBytes("utf-8"));
|
||||
chunks.write(Utf8Helper.getBytes("data"));
|
||||
writeLE(chunks, pcmData.length, 4);
|
||||
chunks.write(pcmData);
|
||||
|
||||
fos.write("RIFF".getBytes("utf-8"));
|
||||
fos.write(Utf8Helper.getBytes("RIFF"));
|
||||
byte[] chunkBytes = chunks.toByteArray();
|
||||
writeLE(fos, 4 + chunkBytes.length, 4);
|
||||
fos.write("WAVE".getBytes("utf-8"));
|
||||
fos.write(Utf8Helper.getBytes("WAVE"));
|
||||
fos.write(chunkBytes);
|
||||
//size1=>16bit*/
|
||||
} finally {
|
||||
@@ -1359,9 +1368,9 @@ public final class SWF {
|
||||
public void run() throws IOException {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
if (formatted) {
|
||||
fos.write(((TextTag) t).getFormattedText(ttags).getBytes("UTF-8"));
|
||||
fos.write(Utf8Helper.getBytes(((TextTag) t).getFormattedText(ttags)));
|
||||
} else {
|
||||
fos.write(((TextTag) t).getText(ttags).getBytes("UTF-8"));
|
||||
fos.write(Utf8Helper.getBytes(((TextTag) t).getText(ttags)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1401,7 +1410,7 @@ public final class SWF {
|
||||
@Override
|
||||
public void run() throws IOException {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
fos.write(((ShapeTag) t).toSVG().getBytes("utf-8"));
|
||||
fos.write(Utf8Helper.getBytes(((ShapeTag) t).toSVG()));
|
||||
}
|
||||
}
|
||||
}, handler).run();
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.ProgressListener;
|
||||
import com.jpexs.helpers.ReReadableInputStream;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -240,7 +241,7 @@ public class SWFInputStream extends InputStream {
|
||||
while (true) {
|
||||
r = readEx();
|
||||
if (r == 0) {
|
||||
return new String(baos.toByteArray(), "utf8");
|
||||
return new String(baos.toByteArray(), Utf8Helper.charset);
|
||||
}
|
||||
baos.write(r);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord;
|
||||
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.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -106,7 +107,7 @@ public class SWFOutputStream extends OutputStream {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeString(String value) throws IOException {
|
||||
write(value.getBytes("utf8"));
|
||||
write(Utf8Helper.getBytes(value));
|
||||
write(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,11 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
|
||||
import com.jpexs.decompiler.flash.abc.usages.*;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
|
||||
import java.io.*;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -750,13 +754,8 @@ public class ABC {
|
||||
}
|
||||
|
||||
public void dump(OutputStream os) {
|
||||
PrintStream output;
|
||||
try {
|
||||
output = new PrintStream(os, false, "utf-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return;
|
||||
}
|
||||
Utf8PrintWriter output;
|
||||
output = new Utf8PrintWriter(os);
|
||||
constants.dump(output);
|
||||
for (int i = 0; i < method_info.length; i++) {
|
||||
output.println("MethodInfo[" + i + "]:" + method_info[i].toString(constants, new ArrayList<String>()));
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.*;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.*;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -368,7 +369,7 @@ public class ABCInputStream extends InputStream {
|
||||
public String readString() throws IOException {
|
||||
int length = readU30();
|
||||
byte[] b = safeRead(length);
|
||||
String r = new String(b, "UTF-8");
|
||||
String r = new String(b, Utf8Helper.charset);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.types.*;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.*;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@@ -144,7 +145,7 @@ public class ABCOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
public void writeString(String s) throws IOException {
|
||||
byte[] sbytes = s.getBytes("UTF-8");
|
||||
byte[] sbytes = Utf8Helper.getBytes(s);
|
||||
writeU30(sbytes.length);
|
||||
write(sbytes);
|
||||
}
|
||||
|
||||
@@ -83,8 +83,22 @@ import com.jpexs.decompiler.graph.NotCompileTimeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.decompiler.graph.model.ScriptEndItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -2095,7 +2109,7 @@ public class AVM2Code implements Serializable {
|
||||
toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer);
|
||||
String src = writer.toString();
|
||||
|
||||
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, null, body, info);
|
||||
AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, null, body, info);
|
||||
for (int i = 0; i < acode.code.size(); i++) {
|
||||
if (outputMap.size() > i) {
|
||||
int tpos = outputMap.get(i);
|
||||
@@ -2136,7 +2150,7 @@ public class AVM2Code implements Serializable {
|
||||
HilightedTextWriter writer = new HilightedTextWriter(false);
|
||||
toASMSource(constants, trait, info, body, outputMap, ExportMode.PCODE, writer);
|
||||
String src = writer.toString();
|
||||
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, trait, body, info);
|
||||
AVM2Code acode = ASM3Parser.parse(new StringReader(src), constants, trait, body, info);
|
||||
for (int i = 0; i < acode.code.size(); i++) {
|
||||
if (outputMap.size() > i) {
|
||||
int tpos = outputMap.get(i);
|
||||
|
||||
@@ -20,13 +20,9 @@ import com.jpexs.decompiler.flash.abc.types.Decimal;
|
||||
import com.jpexs.decompiler.flash.abc.types.Multiname;
|
||||
import com.jpexs.decompiler.flash.abc.types.Namespace;
|
||||
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ConstantPool {
|
||||
|
||||
@@ -305,36 +301,29 @@ public class ConstantPool {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void dump(OutputStream os) {
|
||||
PrintStream output;
|
||||
try {
|
||||
output = new PrintStream(os, false, "utf-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(ConstantPool.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return;
|
||||
}
|
||||
public void dump(Utf8PrintWriter writer) {
|
||||
String s = "";
|
||||
for (int i = 1; i < constant_int.size(); i++) {
|
||||
output.println("INT[" + i + "]=" + constant_int.get(i));
|
||||
writer.println("INT[" + i + "]=" + constant_int.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_uint.size(); i++) {
|
||||
output.println("UINT[" + i + "]=" + constant_uint.get(i));
|
||||
writer.println("UINT[" + i + "]=" + constant_uint.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_double.size(); i++) {
|
||||
output.println("Double[" + i + "]=" + constant_double.get(i));
|
||||
writer.println("Double[" + i + "]=" + constant_double.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_string.size(); i++) {
|
||||
output.println("String[" + i + "]=" + constant_string.get(i));
|
||||
writer.println("String[" + i + "]=" + constant_string.get(i));
|
||||
}
|
||||
for (int i = 1; i < constant_namespace.size(); i++) {
|
||||
output.println("Namespace[" + i + "]=" + constant_namespace.get(i).toString(this));
|
||||
writer.println("Namespace[" + i + "]=" + constant_namespace.get(i).toString(this));
|
||||
}
|
||||
for (int i = 1; i < constant_namespace_set.size(); i++) {
|
||||
output.println("NamespaceSet[" + i + "]=" + constant_namespace_set.get(i).toString(this));
|
||||
writer.println("NamespaceSet[" + i + "]=" + constant_namespace_set.get(i).toString(this));
|
||||
}
|
||||
|
||||
for (int i = 1; i < constant_multiname.size(); i++) {
|
||||
output.println("Multiname[" + i + "]=" + constant_multiname.get(i).toString(this, new ArrayList<String>()));
|
||||
writer.println("Multiname[" + i + "]=" + constant_multiname.get(i).toString(this, new ArrayList<String>()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,11 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class ApplyTypeIns extends InstructionDefinition {
|
||||
|
||||
|
||||
@@ -34,15 +34,11 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ASM3Parser {
|
||||
|
||||
@@ -77,8 +73,8 @@ public class ASM3Parser {
|
||||
}
|
||||
}
|
||||
|
||||
public static AVM2Code parse(InputStream is, ConstantPool constants, Trait trait, MethodBody body, MethodInfo info) throws IOException, ParseException {
|
||||
return parse(is, constants, trait, null, body, info);
|
||||
public static AVM2Code parse(Reader reader, ConstantPool constants, Trait trait, MethodBody body, MethodInfo info) throws IOException, ParseException {
|
||||
return parse(reader, constants, trait, null, body, info);
|
||||
}
|
||||
|
||||
private static int checkMultinameIndex(ConstantPool constants, int index, int line) throws ParseException {
|
||||
@@ -101,14 +97,8 @@ public class ASM3Parser {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean parseSlotConst(InputStream is, ConstantPool constants, TraitSlotConst tsc) throws IOException, ParseException {
|
||||
Flasm3Lexer lexer = null;
|
||||
try {
|
||||
lexer = new Flasm3Lexer(new InputStreamReader(is, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(ASM3Parser.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return false;
|
||||
}
|
||||
public static boolean parseSlotConst(Reader reader, ConstantPool constants, TraitSlotConst tsc) throws IOException, ParseException {
|
||||
Flasm3Lexer lexer = new Flasm3Lexer(reader);
|
||||
expected(ParsedSymbol.TYPE_KEYWORD_TRAIT, "trait", lexer);
|
||||
int name_index = parseMultiName(constants, lexer);
|
||||
|
||||
@@ -483,7 +473,7 @@ public class ASM3Parser {
|
||||
return new ValueKind(value_index, value_kind);
|
||||
}
|
||||
|
||||
public static AVM2Code parse(InputStream is, ConstantPool constants, Trait trait, MissingSymbolHandler missingHandler, MethodBody body, MethodInfo info) throws IOException, ParseException {
|
||||
public static AVM2Code parse(Reader reader, ConstantPool constants, Trait trait, MissingSymbolHandler missingHandler, MethodBody body, MethodInfo info) throws IOException, ParseException {
|
||||
AVM2Code code = new AVM2Code();
|
||||
|
||||
List<OffsetItem> offsetItems = new ArrayList<>();
|
||||
@@ -493,7 +483,7 @@ public class ASM3Parser {
|
||||
int offset = 0;
|
||||
|
||||
|
||||
Flasm3Lexer lexer = new Flasm3Lexer(new InputStreamReader(is, "UTF-8"));
|
||||
Flasm3Lexer lexer = new Flasm3Lexer(reader);
|
||||
|
||||
ParsedSymbol symb;
|
||||
AVM2Instruction lastIns = null;
|
||||
|
||||
@@ -66,7 +66,12 @@ import com.jpexs.decompiler.graph.model.ScriptEndItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -655,7 +655,7 @@ public class ActionListReader {
|
||||
|
||||
pos = ip;
|
||||
Action a;
|
||||
Scanner sc = new Scanner(System.in, "utf-8");
|
||||
Scanner sc = new Scanner(System.in);
|
||||
loopip:
|
||||
while (((endip == -1) || (endip > ip)) && (a = actions.get(pos)) != null) {
|
||||
int actionLen = getTotalActionLength(a);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDecrement;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionIncrement;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionStartDrag;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItemPos;
|
||||
|
||||
@@ -18,7 +18,8 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionAdd2;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaType;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionAnd;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitAnd;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitOr;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitXor;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionDivide;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionLess2;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionGreater;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitLShift;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionGreater;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionLess2;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionModulo;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionMultiply;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionEquals2;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionOr;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionDecrement;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionSetMember;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionIncrement;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionSetMember;
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitRShift;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
|
||||
import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf4.ActionSubtract;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.action.model.operations;
|
||||
|
||||
import com.jpexs.decompiler.flash.action.swf5.ActionBitURShift;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphSourceItem;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
|
||||
@@ -128,15 +128,11 @@ import com.jpexs.decompiler.graph.model.ParenthesisItem;
|
||||
import com.jpexs.decompiler.graph.model.SwitchItem;
|
||||
import com.jpexs.decompiler.graph.model.TernarOpItem;
|
||||
import com.jpexs.decompiler.graph.model.WhileItem;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1822,12 +1818,7 @@ public class ActionScriptParser {
|
||||
public List<GraphTargetItem> treeFromString(String str, List<String> constantPool) throws ParseException, IOException {
|
||||
List<GraphTargetItem> retTree = new ArrayList<>();
|
||||
this.constantPool = constantPool;
|
||||
try {
|
||||
lexer = new ActionScriptLexer(new InputStreamReader(new ByteArrayInputStream(str.getBytes("UTF8")), "UTF8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(ActionScriptParser.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return retTree;
|
||||
}
|
||||
lexer = new ActionScriptLexer(new StringReader(str));
|
||||
retTree.addAll(commands(new HashMap<String, Integer>(), false, false, 0));
|
||||
if (lexer.lex().type != SymbolType.EOF) {
|
||||
throw new ParseException("Parsing finisned before end of the file", lexer.yyline());
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.swf4;
|
||||
import com.jpexs.decompiler.flash.action.Action;
|
||||
import com.jpexs.decompiler.flash.action.model.DirectValueActionItem;
|
||||
import com.jpexs.decompiler.flash.action.model.StartDragActionItem;
|
||||
import com.jpexs.decompiler.flash.ecma.*;
|
||||
import com.jpexs.decompiler.flash.ecma.EcmaScript;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.decompiler.flash.configuration;
|
||||
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.utf8.Utf8InputStreamReader;
|
||||
import com.jpexs.helpers.utf8.Utf8OutputStreamWriter;
|
||||
import com.jpexs.proxy.Replacement;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -274,7 +276,7 @@ public class Configuration {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try (PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(replacementsFile), "utf-8"))) {
|
||||
try (PrintWriter pw = new PrintWriter(new Utf8OutputStreamWriter(new FileOutputStream(replacementsFile)))) {
|
||||
for (Replacement r : replacements) {
|
||||
pw.println(r.urlPattern);
|
||||
pw.println(r.targetFile);
|
||||
@@ -293,7 +295,7 @@ public class Configuration {
|
||||
return;
|
||||
}
|
||||
replacements = new ArrayList<>();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(replacementsFile), "utf-8"))) {
|
||||
try (BufferedReader br = new BufferedReader(new Utf8InputStreamReader(new FileInputStream(replacementsFile)))) {
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
Replacement r = new Replacement(s, br.readLine());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.console;
|
||||
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.WString;
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
@@ -26,10 +27,6 @@ import com.sun.jna.platform.win32.Win32Exception;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -38,12 +35,8 @@ import java.util.logging.Logger;
|
||||
public class ContextMenuTools {
|
||||
|
||||
public static String getAppDir() {
|
||||
String appDir = "";
|
||||
try {
|
||||
appDir = new File(URLDecoder.decode(ContextMenuTools.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8")).getParentFile().getAbsolutePath();
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(ContextMenuTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
String path = Utf8Helper.urlDecode(ContextMenuTools.class.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||
String appDir = new File(path).getParentFile().getAbsolutePath();
|
||||
if (!appDir.endsWith("\\")) {
|
||||
appDir += "\\";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jpexs.decompiler.flash.flv;
|
||||
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
@@ -137,15 +138,15 @@ public class FLVOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
public void writeSCRIPTDATASTRING(String s) throws IOException {
|
||||
int len = s.getBytes("UTF-8").length;
|
||||
writeUI16(len);
|
||||
write(s.getBytes("UTF-8"));
|
||||
byte[] bytes = Utf8Helper.getBytes(s);
|
||||
writeUI16(bytes.length);
|
||||
write(bytes);
|
||||
}
|
||||
|
||||
public void writeSCRIPTDATALONGSTRING(String s) throws IOException {
|
||||
int len = s.getBytes("UTF-8").length;
|
||||
writeUI32(len);
|
||||
write(s.getBytes("UTF-8"));
|
||||
byte[] bytes = Utf8Helper.getBytes(s);
|
||||
writeUI32(bytes.length);
|
||||
write(bytes);
|
||||
}
|
||||
|
||||
private void writeLong(long value) throws IOException {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.jpexs.helpers.Cache;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.ProgressListener;
|
||||
import com.jpexs.helpers.ReReadableInputStream;
|
||||
import com.jpexs.helpers.utf8.Utf8PrintWriter;
|
||||
import com.sun.jna.Platform;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -608,11 +609,7 @@ public class Main {
|
||||
} else {
|
||||
if (f.getName().endsWith(".java")) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintWriter pw = null;
|
||||
try {
|
||||
pw = new PrintWriter(new OutputStreamWriter(baos, "utf8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
}
|
||||
PrintWriter pw = new Utf8PrintWriter(baos);
|
||||
try {
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(f))) {
|
||||
String s;
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -196,7 +197,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
|
||||
}
|
||||
mb.code.compact();
|
||||
} else {
|
||||
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(text.getBytes("UTF-8")), constants, trait, new MissingSymbolHandler() {
|
||||
AVM2Code acode = ASM3Parser.parse(new StringReader(text), constants, trait, new MissingSymbolHandler() {
|
||||
//no longer ask for adding new constants
|
||||
@Override
|
||||
public boolean missingString(String value) {
|
||||
|
||||
@@ -26,9 +26,8 @@ import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import java.awt.BorderLayout;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -110,15 +109,12 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail {
|
||||
@Override
|
||||
public boolean save() {
|
||||
try {//(slotConstEditor.getText(), trait, abc)
|
||||
if (!ASM3Parser.parseSlotConst(new ByteArrayInputStream(slotConstEditor.getText().getBytes("UTF-8")), abc.constants, trait)) {
|
||||
if (!ASM3Parser.parseSlotConst(new StringReader(slotConstEditor.getText()), abc.constants, trait)) {
|
||||
return false;
|
||||
}
|
||||
} catch (ParseException ex) {
|
||||
View.showMessageDialog(slotConstEditor, ex.text, AppStrings.translate("error.slotconst.typevalue"), JOptionPane.ERROR_MESSAGE);
|
||||
return false;
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(SlotConstTraitDetailPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return false;
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(SlotConstTraitDetailPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return false;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.jpexs.decompiler.flash.gui.player;
|
||||
|
||||
import com.jpexs.decompiler.flash.gui.FlashUnsupportedException;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import com.sun.jna.Native;
|
||||
import com.sun.jna.Platform;
|
||||
import com.sun.jna.WString;
|
||||
@@ -18,8 +18,6 @@ import java.awt.Panel;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.io.File;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -220,12 +218,8 @@ public class FlashPlayerPanel extends Panel implements FlashDisplay {
|
||||
|
||||
SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO();
|
||||
sei.fMask = 0x00000040;
|
||||
String appDir = "";
|
||||
try {
|
||||
appDir = new File(URLDecoder.decode(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8")).getParentFile().getAbsolutePath();
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(FlashPlayerPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
String path = Utf8Helper.urlDecode(FlashPlayerPanel.class.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||
String appDir = new File(path).getParentFile().getAbsolutePath();
|
||||
if (!appDir.endsWith("\\")) {
|
||||
appDir += "\\";
|
||||
}
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.helpers;
|
||||
|
||||
import com.jpexs.helpers.utf8.Utf8OutputStreamWriter;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -37,8 +36,8 @@ public class FileTextWriter extends GraphTextWriter implements AutoCloseable {
|
||||
private int indent;
|
||||
private int writtenBytes;
|
||||
|
||||
public FileTextWriter(FileOutputStream fos) throws UnsupportedEncodingException {
|
||||
this.writer = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
|
||||
public FileTextWriter(FileOutputStream fos) {
|
||||
this.writer = new BufferedWriter(new Utf8OutputStreamWriter(fos));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,8 +32,8 @@ import java.awt.geom.GeneralPath;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.StringReader;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -165,7 +165,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
@Override
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text, String fontName) throws ParseException {
|
||||
try {
|
||||
TextLexer lexer = new TextLexer(new InputStreamReader(new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8"));
|
||||
TextLexer lexer = new TextLexer(new StringReader(text));
|
||||
ParsedSymbol s = null;
|
||||
text = "";
|
||||
RECT bounds = new RECT(this.bounds);
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.types.LANGCODE;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.Font;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -102,8 +103,9 @@ public class DefineFont2Tag extends FontTag {
|
||||
sos.writeUB(1, fontFlagsItalic ? 1 : 0);
|
||||
sos.writeUB(1, fontFlagsBold ? 1 : 0);
|
||||
sos.writeLANGCODE(languageCode);
|
||||
sos.writeUI8(fontName.getBytes("utf-8").length);
|
||||
sos.write(fontName.getBytes("utf-8"));
|
||||
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
|
||||
sos.writeUI8(fontNameBytes.length);
|
||||
sos.write(fontNameBytes);
|
||||
sos.writeUI16(numGlyphs);
|
||||
|
||||
List<Long> offsetTable = new ArrayList<>();
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.types.LANGCODE;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.Font;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -177,8 +178,9 @@ public class DefineFont3Tag extends FontTag {
|
||||
sos.writeUB(1, fontFlagsItalic ? 1 : 0);
|
||||
sos.writeUB(1, fontFlagsBold ? 1 : 0);
|
||||
sos.writeLANGCODE(languageCode);
|
||||
sos.writeUI8(fontName.getBytes("utf-8").length);
|
||||
sos.write(fontName.getBytes("utf-8"));
|
||||
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
|
||||
sos.writeUI8(fontNameBytes.length);
|
||||
sos.write(fontNameBytes);
|
||||
sos.writeUI16(numGlyphs);
|
||||
|
||||
List<Long> offsetTable = new ArrayList<>();
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.types.LANGCODE;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -59,8 +60,9 @@ public class DefineFontInfo2Tag extends Tag {
|
||||
SWFOutputStream sos = new SWFOutputStream(os, version);
|
||||
try {
|
||||
sos.writeUI16(fontID);
|
||||
sos.writeUI8(fontName.getBytes("utf-8").length);
|
||||
sos.write(fontName.getBytes("utf-8"));
|
||||
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
|
||||
sos.writeUI8(fontNameBytes.length);
|
||||
sos.write(fontNameBytes);
|
||||
sos.writeUB(2, 0);
|
||||
sos.writeUB(1, fontFlagsSmallText ? 1 : 0);
|
||||
sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0);
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.tags;
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -57,8 +58,9 @@ public class DefineFontInfoTag extends Tag {
|
||||
SWFOutputStream sos = new SWFOutputStream(os, version);
|
||||
try {
|
||||
sos.writeUI16(fontId);
|
||||
sos.writeUI8(fontName.getBytes("utf-8").length);
|
||||
sos.write(fontName.getBytes("utf-8"));
|
||||
byte[] fontNameBytes = Utf8Helper.getBytes(fontName);
|
||||
sos.writeUI8(fontNameBytes.length);
|
||||
sos.write(fontNameBytes);
|
||||
sos.writeUB(2, 0); //reserved
|
||||
sos.writeUB(1, fontFlagsSmallText ? 1 : 0);
|
||||
sos.writeUB(1, fontFlagsShiftJIS ? 1 : 0);
|
||||
|
||||
@@ -38,17 +38,14 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -159,7 +156,7 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text, String fontName) throws ParseException {
|
||||
List<TEXTRECORD> oldTextRecords = textRecords;
|
||||
try {
|
||||
TextLexer lexer = new TextLexer(new InputStreamReader(new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8"));
|
||||
TextLexer lexer = new TextLexer(new StringReader(text));
|
||||
ParsedSymbol s = null;
|
||||
textRecords = new ArrayList<>();
|
||||
RGBA colorA = null;
|
||||
@@ -386,8 +383,6 @@ public class DefineText2Tag extends TextTag implements DrawableTag {
|
||||
this.textBounds = textBounds;
|
||||
//this.textBounds.Xmin = minX;
|
||||
//this.textBounds.Xmax = maxX;
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(DefineText2Tag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
textRecords = oldTextRecords;
|
||||
return false;
|
||||
|
||||
@@ -38,17 +38,14 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -159,7 +156,7 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
public boolean setFormattedText(MissingCharacterHandler missingCharHandler, List<Tag> tags, String text, String fontName) throws ParseException {
|
||||
List<TEXTRECORD> oldTextRecords = textRecords;
|
||||
try {
|
||||
TextLexer lexer = new TextLexer(new InputStreamReader(new ByteArrayInputStream(text.getBytes("UTF-8")), "UTF-8"));
|
||||
TextLexer lexer = new TextLexer(new StringReader(text));
|
||||
ParsedSymbol s = null;
|
||||
textRecords = new ArrayList<>();
|
||||
RGB color = null;
|
||||
@@ -387,8 +384,6 @@ public class DefineTextTag extends TextTag implements DrawableTag {
|
||||
this.textBounds = textBounds;
|
||||
//this.textBounds.Xmin = minX;
|
||||
//this.textBounds.Xmax = maxX;
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(DefineTextTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
textRecords = oldTextRecords;
|
||||
return false;
|
||||
|
||||
@@ -22,7 +22,11 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,11 @@ import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import java.io.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,6 +91,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord;
|
||||
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
|
||||
import com.jpexs.decompiler.flash.types.sound.MP3FRAME;
|
||||
import com.jpexs.decompiler.graph.ExportMode;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
@@ -100,10 +101,8 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -1282,11 +1281,7 @@ public class XFLConverter {
|
||||
symbolStr += "</DOMSymbolItem>";
|
||||
symbolStr = prettyFormatXML(symbolStr);
|
||||
String symbolFile = "Symbol " + symbol.getCharacterId() + ".xml";
|
||||
try {
|
||||
files.put(symbolFile, symbolStr.getBytes("UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
files.put(symbolFile, Utf8Helper.getBytes(symbolStr));
|
||||
String symbLinkStr = "";
|
||||
symbLinkStr += "<Include href=\"" + symbolFile + "\"";
|
||||
if (itemIcon != null) {
|
||||
@@ -2608,11 +2603,7 @@ public class XFLConverter {
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
writeFile(handler, data.getBytes("UTF-8"), outDir.getAbsolutePath() + File.separator + expPath + ".as");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
writeFile(handler, Utf8Helper.getBytes(data), outDir.getAbsolutePath() + File.separator + expPath + ".as");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2835,9 +2826,9 @@ public class XFLConverter {
|
||||
public void run() throws IOException {
|
||||
try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outfileF))) {
|
||||
out.putNextEntry(new ZipEntry("DOMDocument.xml"));
|
||||
out.write(domDocumentF.getBytes("UTF-8"));
|
||||
out.write(Utf8Helper.getBytes(domDocumentF));
|
||||
out.putNextEntry(new ZipEntry("PublishSettings.xml"));
|
||||
out.write(publishSettingsF.getBytes("UTF-8"));
|
||||
out.write(Utf8Helper.getBytes(publishSettingsF));
|
||||
for (String fileName : files.keySet()) {
|
||||
out.putNextEntry(new ZipEntry("LIBRARY/" + fileName));
|
||||
out.write(files.get(fileName));
|
||||
@@ -2860,16 +2851,8 @@ public class XFLConverter {
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
writeFile(handler, domDocument.getBytes("UTF-8"), outDir.getAbsolutePath() + File.separator + "DOMDocument.xml");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
try {
|
||||
writeFile(handler, publishSettings.getBytes("UTF-8"), outDir.getAbsolutePath() + File.separator + "PublishSettings.xml");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
writeFile(handler, Utf8Helper.getBytes(domDocument), outDir.getAbsolutePath() + File.separator + "DOMDocument.xml");
|
||||
writeFile(handler, Utf8Helper.getBytes(publishSettings), outDir.getAbsolutePath() + File.separator + "PublishSettings.xml");
|
||||
File libraryDir = new File(outDir.getAbsolutePath() + File.separator + "LIBRARY");
|
||||
libraryDir.mkdir();
|
||||
File binDir = new File(outDir.getAbsolutePath() + File.separator + "bin");
|
||||
@@ -2880,11 +2863,7 @@ public class XFLConverter {
|
||||
for (String fileName : datfiles.keySet()) {
|
||||
writeFile(handler, datfiles.get(fileName), binDir.getAbsolutePath() + File.separator + fileName);
|
||||
}
|
||||
try {
|
||||
writeFile(handler, "PROXY-CS5".getBytes("utf-8"), outfile);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
writeFile(handler, Utf8Helper.getBytes("PROXY-CS5"), outfile);
|
||||
}
|
||||
if (useAS3) {
|
||||
try {
|
||||
@@ -3024,7 +3003,7 @@ public class XFLConverter {
|
||||
+ "<!ENTITY nbsp \" \"> \n"
|
||||
+ "]><html>" + html + "</html>";
|
||||
try {
|
||||
parser.parse(new InputSource(new InputStreamReader(new ByteArrayInputStream(html.getBytes("UTF-8")), "UTF-8")));
|
||||
parser.parse(new InputSource(new StringReader(html)));
|
||||
} catch (SAXParseException spe) {
|
||||
System.out.println(html);
|
||||
System.err.println(tparser.result);
|
||||
@@ -3036,7 +3015,7 @@ public class XFLConverter {
|
||||
reader.setErrorHandler(tparser);
|
||||
reader.setEntityResolver(tparser);
|
||||
html = "<html>" + html + "</html>";
|
||||
reader.parse(new InputSource(new InputStreamReader(new ByteArrayInputStream(html.getBytes("UTF-8")), "UTF-8")));*/
|
||||
reader.parse(new InputSource(new StringReader(html)));*/
|
||||
|
||||
} catch (SAXException | IOException e) {
|
||||
Logger.getLogger(XFLConverter.class.getName()).log(Level.SEVERE, "Error while converting HTML", e);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.Component;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -31,7 +32,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -491,13 +491,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
public static String strToHex(String s) {
|
||||
byte[] bs;
|
||||
try {
|
||||
bs = s.getBytes("utf-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
bs = new byte[0];
|
||||
Logger.getLogger(Helper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
byte[] bs = Utf8Helper.getBytes(s);
|
||||
String sn = "";
|
||||
for (int i = 0; i < bs.length; i++) {
|
||||
sn += "0x" + Integer.toHexString(bs[i] & 0xff) + " ";
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.helpers.utf8;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Utf8Helper {
|
||||
|
||||
public static Charset charset = Charset.forName("UTF-8");
|
||||
|
||||
public static String urlDecode(String s) {
|
||||
try {
|
||||
return URLDecoder.decode(s, "UTF-8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] getBytes(String string) {
|
||||
return string.getBytes(charset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.helpers.utf8;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Utf8InputStreamReader extends InputStreamReader {
|
||||
|
||||
public Utf8InputStreamReader(InputStream in) {
|
||||
super(in, Utf8Helper.charset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.helpers.utf8;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Utf8OutputStreamWriter extends OutputStreamWriter {
|
||||
|
||||
public Utf8OutputStreamWriter(OutputStream out) {
|
||||
super(out, Utf8Helper.charset);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.helpers.utf8;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Utf8PrintWriter extends PrintWriter {
|
||||
|
||||
public Utf8PrintWriter(OutputStream out) {
|
||||
super(new Utf8OutputStreamWriter(out));
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.jpexs.decompiler.flash.tags.DoABCDefineTag;
|
||||
import com.jpexs.decompiler.flash.tags.DoActionTag;
|
||||
import com.jpexs.decompiler.flash.tags.ShowFrameTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@@ -77,7 +78,7 @@ public class AS2Generator {
|
||||
pw.println(s.toString());
|
||||
}*/
|
||||
try (FileOutputStream fos = new FileOutputStream("as2_teststub.java")) {
|
||||
fos.write(s.toString().getBytes("UTF-8"));
|
||||
fos.write(Utf8Helper.getBytes(s.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user