diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 8b13c55c8..ff8e1c654 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -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(); diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 27de1e4c3..ba61a4c10 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 2f0f84e05..a660c6d18 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index 660a303b4..4d91a2cc5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -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())); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java index 8b76d9fd9..192a926d0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java @@ -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; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java index cfda6c601..5e60e1d6a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index e5ad968bc..36ae75e87 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java index d9a246032..2d52ab8d1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java @@ -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())); + writer.println("Multiname[" + i + "]=" + constant_multiname.get(i).toString(this, new ArrayList())); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java index deac2f9aa..9204a4b42 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java @@ -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 { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java index cfc087b9a..b68fe787a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java @@ -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 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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index a4ae0d623..dca7d9bf0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java index 07f6f9734..e16882813 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java index a2d7563d6..63262dd51 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java index d414b31d5..a3a7c995e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java index 59da34ded..b86811b07 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java index a5aa8488c..1baca85eb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AndActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AndActionItem.java index 09f4e9d30..489df3b68 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AndActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AndActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java index ac923bed9..a7384073b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitAndActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java index c6e89761e..92cde8c61 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitOrActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java index 35aa9579c..48ec20e6c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/BitXorActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/DivideActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/DivideActionItem.java index 80f05efa5..ddc415ba4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/DivideActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/DivideActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/EqActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/EqActionItem.java index 0d1ac1a21..007816307 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/EqActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/EqActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java index 2c99c65d0..64ce76bae 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GeActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java index 26d31364a..a93c3b653 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/GtActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LShiftActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LShiftActionItem.java index 8264fdde4..f52b8fdb5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LShiftActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LShiftActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java index 017871ad5..2298ad77b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LeActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java index 3feaeaa4f..0e7d8aa94 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/LtActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/ModuloActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/ModuloActionItem.java index 5414be495..cad165ac3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/ModuloActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/ModuloActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/MultiplyActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/MultiplyActionItem.java index 0371e1fb0..44d11b8ee 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/MultiplyActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/MultiplyActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/NeqActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/NeqActionItem.java index a8cb6f492..4a5c274bc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/NeqActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/NeqActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/OrActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/OrActionItem.java index da721ebe9..39e53c188 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/OrActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/OrActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreDecrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreDecrementActionItem.java index 0cbd07578..5b2bd2461 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreDecrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreDecrementActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreIncrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreIncrementActionItem.java index e8d46f81d..ccc39aa79 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreIncrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/PreIncrementActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/RShiftActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/RShiftActionItem.java index c866a9e62..50fe8f61a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/RShiftActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/RShiftActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictEqActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictEqActionItem.java index a4d438ee1..d3ffbda0b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictEqActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictEqActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictNeqActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictNeqActionItem.java index 0f9558885..b7d19d158 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictNeqActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/StrictNeqActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java index a97f20ac7..7d163997d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/URShiftActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/URShiftActionItem.java index d2afcba00..21c9613d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/URShiftActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/URShiftActionItem.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java index e8da5fbc5..85a5376de 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptParser.java @@ -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 treeFromString(String str, List constantPool) throws ParseException, IOException { List 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(), false, false, 0)); if (lexer.lex().type != SymbolType.EOF) { throw new ParseException("Parsing finisned before end of the file", lexer.yyline()); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java index 65e23be0e..528d29164 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 348ae5d32..8c6fd540c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -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()); diff --git a/trunk/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java b/trunk/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java index 854dcf828..00990c36d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java +++ b/trunk/src/com/jpexs/decompiler/flash/console/ContextMenuTools.java @@ -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 += "\\"; } diff --git a/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java index 978c488ee..1f5f77528 100644 --- a/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/flv/FLVOutputStream.java @@ -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 { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 8e1f18ed2..0a0b7dddc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index ab8494bf6..8e8a8e9a8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -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) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java index 0201ad8cb..a9993dbba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java index a1aae678a..7d86b6530 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/player/FlashPlayerPanel.java @@ -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 += "\\"; } diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java b/trunk/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java index d208a1a83..411f55f6b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/FileTextWriter.java @@ -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 diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index 26f8ce7e5..1266db370 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -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 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); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index 3ae1aa776..500ecd3a1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -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 offsetTable = new ArrayList<>(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 9c9741212..5bb50a699 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -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 offsetTable = new ArrayList<>(); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java index 7ee5dcc9e..df2c76a1b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfo2Tag.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java index 6a54904a3..d127b31ba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineFontInfoTag.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java index 39a5a1c1f..19421cba5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineText2Tag.java @@ -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 tags, String text, String fontName) throws ParseException { List 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; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java index dca4cae55..314a92e2a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineTextTag.java @@ -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 tags, String text, String fontName) throws ParseException { List 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; diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java index ffb9a83de..738d2cf38 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java @@ -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; /** diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java index 18d17e913..f763e66af 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java @@ -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; /** diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index 8d3256b74..7b8f1eb9a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -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 += ""; 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 += " \n" + "]>" + 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 + ""; - 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); diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index 6cbc8b39c..a98d64828 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -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) + " "; diff --git a/trunk/src/com/jpexs/helpers/utf8/Utf8Helper.java b/trunk/src/com/jpexs/helpers/utf8/Utf8Helper.java new file mode 100644 index 000000000..98e399608 --- /dev/null +++ b/trunk/src/com/jpexs/helpers/utf8/Utf8Helper.java @@ -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 . + */ +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); + } +} diff --git a/trunk/src/com/jpexs/helpers/utf8/Utf8InputStreamReader.java b/trunk/src/com/jpexs/helpers/utf8/Utf8InputStreamReader.java new file mode 100644 index 000000000..e752e2ea4 --- /dev/null +++ b/trunk/src/com/jpexs/helpers/utf8/Utf8InputStreamReader.java @@ -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 . + */ +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); + } +} diff --git a/trunk/src/com/jpexs/helpers/utf8/Utf8OutputStreamWriter.java b/trunk/src/com/jpexs/helpers/utf8/Utf8OutputStreamWriter.java new file mode 100644 index 000000000..091e39f19 --- /dev/null +++ b/trunk/src/com/jpexs/helpers/utf8/Utf8OutputStreamWriter.java @@ -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 . + */ +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); + } +} diff --git a/trunk/src/com/jpexs/helpers/utf8/Utf8PrintWriter.java b/trunk/src/com/jpexs/helpers/utf8/Utf8PrintWriter.java new file mode 100644 index 000000000..17eadd4eb --- /dev/null +++ b/trunk/src/com/jpexs/helpers/utf8/Utf8PrintWriter.java @@ -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 . + */ +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)); + } +} diff --git a/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java b/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java index 96fb874f1..42cba7338 100644 --- a/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java @@ -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())); } } }