mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-04 10:15:17 +00:00
allow to create swf from code only / export SWF to "Java code", which generates the SWF
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.helpers;
|
||||
|
||||
import com.jpexs.decompiler.flash.AppResources;
|
||||
@@ -179,6 +180,42 @@ public class Helper {
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes string by adding backslashes
|
||||
*
|
||||
* @param s String to escape
|
||||
* @return Escaped string
|
||||
*/
|
||||
public static String escapeJavaString(String s) {
|
||||
StringBuilder ret = new StringBuilder(s.length());
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
if (c == '\n') {
|
||||
ret.append("\\n");
|
||||
} else if (c == '\r') {
|
||||
ret.append("\\r");
|
||||
} else if (c == '\t') {
|
||||
ret.append("\\t");
|
||||
} else if (c == '\b') {
|
||||
ret.append("\\b");
|
||||
} else if (c == '\t') {
|
||||
ret.append("\\t");
|
||||
} else if (c == '\f') {
|
||||
ret.append("\\f");
|
||||
} else if (c == '\\') {
|
||||
ret.append("\\\\");
|
||||
} else if (c == '"') {
|
||||
ret.append("\\\"");
|
||||
} else if (c < 32) {
|
||||
ret.append("\\u").append(padZeros(Integer.toHexString((int) c), 4));
|
||||
} else {
|
||||
ret.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return ret.toString();
|
||||
}
|
||||
|
||||
public static String getValidHtmlId(String text) {
|
||||
// ID and NAME tokens must begin with a letter ([A-Za-z]) and
|
||||
// may be followed by any number of letters, digits ([0-9]),
|
||||
|
||||
Reference in New Issue
Block a user