core: Fix non-ASCII characters input in EditText
Casting the character to u8 and back to char caused some non-ASCII non-control characters to be treated as control characters. For instance the letter "ą" (U+0105) after casting to u8 and back became ENQ (U+0005) which is a control character. Some other letters worked, for instance the letter "ł" (U+0142) became "B" (U+0042) and was not classified as a control character. The test edittext_input was added to verify this behavior.
This commit is contained in:
parent
217585daa8
commit
47deaf50a2
|
@ -1475,9 +1475,7 @@ impl<'gc> EditText<'gc> {
|
|||
if let Some(selection) = self.selection() {
|
||||
let mut changed = false;
|
||||
let mut cancelled = false;
|
||||
match character as u8 {
|
||||
code if !(code as char).is_control() => {
|
||||
if self.available_chars() > 0 {
|
||||
if !character.is_control() && self.available_chars() > 0 {
|
||||
if let Avm2Value::Object(target) = self.object2() {
|
||||
let character_string =
|
||||
AvmString::new_utf8(context.gc_context, character.to_string());
|
||||
|
@ -1510,9 +1508,6 @@ impl<'gc> EditText<'gc> {
|
|||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
if changed {
|
||||
let mut activation = Avm1Activation::from_nothing(
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
[
|
||||
{ "type": "TextInput", "codepoint": "a" },
|
||||
{ "type": "TextInput", "codepoint": "b" },
|
||||
{ "type": "TextInput", "codepoint": "c" },
|
||||
{ "type": "TextInput", "codepoint": "A" },
|
||||
{ "type": "TextInput", "codepoint": "B" },
|
||||
{ "type": "TextInput", "codepoint": "C" },
|
||||
{ "type": "TextInput", "codepoint": "~" },
|
||||
{ "type": "TextInput", "codepoint": "!" },
|
||||
{ "type": "TextInput", "codepoint": "@" },
|
||||
{ "type": "TextInput", "codepoint": "#" },
|
||||
{ "type": "TextInput", "codepoint": "$" },
|
||||
{ "type": "TextInput", "codepoint": "%" },
|
||||
{ "type": "TextInput", "codepoint": "^" },
|
||||
{ "type": "TextInput", "codepoint": "&" },
|
||||
{ "type": "TextInput", "codepoint": "*" },
|
||||
{ "type": "TextInput", "codepoint": "(" },
|
||||
{ "type": "TextInput", "codepoint": ")" },
|
||||
{ "type": "TextInput", "codepoint": "`" },
|
||||
{ "type": "TextInput", "codepoint": "-" },
|
||||
{ "type": "TextInput", "codepoint": "=" },
|
||||
{ "type": "TextInput", "codepoint": "_" },
|
||||
{ "type": "TextInput", "codepoint": "+" },
|
||||
{ "type": "TextInput", "codepoint": "/" },
|
||||
{ "type": "TextInput", "codepoint": "?" },
|
||||
{ "type": "TextInput", "codepoint": "|" },
|
||||
{ "type": "TextInput", "codepoint": "ą" },
|
||||
{ "type": "TextInput", "codepoint": "ę" },
|
||||
{ "type": "TextInput", "codepoint": "ć" },
|
||||
{ "type": "TextInput", "codepoint": "ł" },
|
||||
{ "type": "TextInput", "codepoint": "þ" },
|
||||
{ "type": "TextInput", "codepoint": "ó" },
|
||||
{ "type": "TextInput", "codepoint": "→" },
|
||||
{ "type": "TextInput", "codepoint": "↓" },
|
||||
{ "type": "TextInput", "codepoint": "ß" },
|
||||
{ "type": "TextInput", "codepoint": "©" },
|
||||
{ "type": "TextInput", "codepoint": "ę" },
|
||||
{ "type": "TextInput", "codepoint": "œ" },
|
||||
{ "type": "TextInput", "codepoint": "π" },
|
||||
{ "type": "TextInput", "codepoint": "ą" },
|
||||
{ "type": "TextInput", "codepoint": "ś" },
|
||||
{ "type": "TextInput", "codepoint": "ð" },
|
||||
{ "type": "TextInput", "codepoint": "æ" },
|
||||
{ "type": "TextInput", "codepoint": "ŋ" },
|
||||
{ "type": "TextInput", "codepoint": "’" },
|
||||
{ "type": "TextInput", "codepoint": "ə" },
|
||||
{ "type": "TextInput", "codepoint": "…" },
|
||||
{ "type": "TextInput", "codepoint": "ł" },
|
||||
{ "type": "TextInput", "codepoint": "ź" },
|
||||
{ "type": "TextInput", "codepoint": "ć" },
|
||||
{ "type": "TextInput", "codepoint": "ż" },
|
||||
{ "type": "TextInput", "codepoint": "„" },
|
||||
{ "type": "TextInput", "codepoint": "”" },
|
||||
{ "type": "TextInput", "codepoint": "ń" },
|
||||
{ "type": "TextInput", "codepoint": "µ" },
|
||||
{ "type": "TextInput", "codepoint": "≤" },
|
||||
{ "type": "TextInput", "codepoint": "≥" },
|
||||
{ "type": "TextInput", "codepoint": "≠" },
|
||||
{ "type": "TextInput", "codepoint": "²" },
|
||||
{ "type": "TextInput", "codepoint": "³" },
|
||||
{ "type": "TextInput", "codepoint": "¢" },
|
||||
{ "type": "TextInput", "codepoint": "€" },
|
||||
{ "type": "TextInput", "codepoint": "½" },
|
||||
{ "type": "TextInput", "codepoint": "§" },
|
||||
{ "type": "TextInput", "codepoint": "·" },
|
||||
{ "type": "TextInput", "codepoint": "«" },
|
||||
{ "type": "TextInput", "codepoint": "»" },
|
||||
{ "type": "TextInput", "codepoint": "–" },
|
||||
{ "type": "TextInput", "codepoint": "—" },
|
||||
{ "type": "TextInput", "codepoint": "°" },
|
||||
{ "type": "TextInput", "codepoint": "±" },
|
||||
{ "type": "TextInput", "codepoint": "¾" },
|
||||
{ "type": "TextInput", "codepoint": "≈" },
|
||||
{ "type": "TextInput", "codepoint": "∧" },
|
||||
{ "type": "TextInput", "codepoint": "‰" },
|
||||
{ "type": "TextInput", "codepoint": "¼" },
|
||||
{ "type": "TextInput", "codepoint": "£" },
|
||||
{ "type": "TextInput", "codepoint": "¿" },
|
||||
{ "type": "TextInput", "codepoint": "¡" },
|
||||
{ "type": "TextInput", "codepoint": "Ƈ" },
|
||||
{ "type": "TextInput", "codepoint": "ƌ" },
|
||||
{ "type": "TextInput", "codepoint": "ƣ" },
|
||||
{ "type": "TextInput", "codepoint": "Ʊ" },
|
||||
{ "type": "TextInput", "codepoint": "Lj" },
|
||||
{ "type": "TextInput", "codepoint": "Ǎ" },
|
||||
{ "type": "TextInput", "codepoint": "Ǜ" },
|
||||
{ "type": "TextInput", "codepoint": "ǭ" },
|
||||
{ "type": "TextInput", "codepoint": "Ǽ" },
|
||||
{ "type": "TextInput", "codepoint": "ȉ" },
|
||||
{ "type": "TextInput", "codepoint": "ȥ" },
|
||||
{ "type": "TextInput", "codepoint": "ȹ" },
|
||||
{ "type": "TextInput", "codepoint": "Ɍ" },
|
||||
{ "type": "TextInput", "codepoint": "ɏ" },
|
||||
{ "type": "TextInput", "codepoint": "Ḑ" },
|
||||
{ "type": "TextInput", "codepoint": "ṁ" },
|
||||
{ "type": "TextInput", "codepoint": "Ṥ" },
|
||||
{ "type": "TextInput", "codepoint": "Ẉ" },
|
||||
{ "type": "TextInput", "codepoint": "ẟ" },
|
||||
{ "type": "TextInput", "codepoint": "Ắ" },
|
||||
{ "type": "TextInput", "codepoint": "ố" },
|
||||
{ "type": "TextInput", "codepoint": "ỳ" },
|
||||
{ "type": "TextInput", "codepoint": "ỿ" },
|
||||
{ "type": "TextInput", "codepoint": "Ⱨ" },
|
||||
{ "type": "TextInput", "codepoint": "Ȿ" },
|
||||
{ "type": "TextInput", "codepoint": "Ꞧ" },
|
||||
{ "type": "TextInput", "codepoint": "Ꞁ" },
|
||||
{ "type": "TextInput", "codepoint": "Ꞿ" },
|
||||
{ "type": "TextInput", "codepoint": "ꟿ" },
|
||||
{ "type": "TextInput", "codepoint": "ꭧ" },
|
||||
{ "type": "TextInput", "codepoint": "𐞔" },
|
||||
{ "type": "TextInput", "codepoint": "𐞮" },
|
||||
{ "type": "TextInput", "codepoint": "𝼙" },
|
||||
{ "type": "TextInput", "codepoint": "𝼞" },
|
||||
{ "type": "TextInput", "codepoint": "စ" },
|
||||
{ "type": "KeyDown", "key_code": 27 }
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from os import path
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
input_file = path.join(path.dirname(__file__), 'input.txt')
|
||||
with open(input_file, 'r', encoding='utf-8') as file:
|
||||
characters = file.read().replace(' ', '').replace('\n', '')
|
||||
|
||||
print('[')
|
||||
for ch in characters:
|
||||
print(f' {{ "type": "TextInput", "codepoint": "{ch}" }},')
|
||||
|
||||
print(f' {{ "type": "KeyDown", "key_code": 27 }}')
|
||||
|
||||
print(']')
|
|
@ -0,0 +1 @@
|
|||
abcABC~!@#$%^&*()`-=_+/?|ąęćłþó→↓ß©ęœπąśðæŋ’ə…łźćż„”ńµ≤≥≠²³¢€½§·«»–—°±¾≈∧‰¼£¿¡ƇƌƣƱLjǍǛǭǼȉȥȹɌɏḐṁṤẈẟẮốỳỿⱧⱾꞦꞀꞾꟿꭧ𐞔𐞮𝼙𝼞စ
|
|
@ -0,0 +1 @@
|
|||
abcABC~!@#$%^&*()`-=_+/?|ąęćłþó→↓ß©ęœπąśðæŋ’ə…łźćż„”ńµ≤≥≠²³¢€½§·«»–—°±¾≈∧‰¼£¿¡ƇƌƣƱLjǍǛǭǼȉȥȹɌɏḐṁṤẈẟẮốỳỿⱧⱾꞦꞀꞾꟿꭧ𐞔𐞮𝼙𝼞စ
|
|
@ -0,0 +1,9 @@
|
|||
var listener = new Object();
|
||||
listener.onKeyDown = function() {
|
||||
if (Key.getCode() == 27) {
|
||||
trace(text.text);
|
||||
}
|
||||
};
|
||||
Key.addListener(listener);
|
||||
|
||||
Selection.setFocus(text);
|
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
num_frames = 1
|
Loading…
Reference in New Issue