Fixed: AS1/2 actions must use SWF charset when writing its length

This commit is contained in:
Jindra Petřík
2025-08-19 18:14:41 +02:00
parent a84cdd3682
commit 1c88c0304b
9 changed files with 27 additions and 13 deletions
@@ -152,6 +152,17 @@ public class Utf8Helper {
// todo: make it faster without actually writing it to an array
return getBytes(string).length;
}
public static int getBytesLength(String string, String charset) {
if (charset.toLowerCase().equals(charsetName)) {
return getBytesLength(string);
}
try {
return string.getBytes(charset).length;
} catch (UnsupportedEncodingException ex) {
return 0; //Should not happen
}
}
private static String escapeInvalidUtf8Char(int v) {
//Note: for writing the string "{invalid_utf8=xxx}" itself, you can escape it with "{+invalid_utf8=xxx}"