From a886f6eedeafbe06c6de0cf68fbd0f81655af597 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sun, 9 Jun 2024 10:35:38 +0200 Subject: compose: Fix misbehaving due to encoding errors Encoding errors in the compose data compiler due to: - 'UTF-16' adds a BOM, use 'UTF-16-LE' instead - 'str.encode' returns a byte array, use 'array' to have a 16-bit char array. --- srcs/juloo.keyboard2/ComposeKey.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'srcs/juloo.keyboard2/ComposeKey.java') diff --git a/srcs/juloo.keyboard2/ComposeKey.java b/srcs/juloo.keyboard2/ComposeKey.java index 328bb83..9272bd0 100644 --- a/srcs/juloo.keyboard2/ComposeKey.java +++ b/srcs/juloo.keyboard2/ComposeKey.java @@ -36,17 +36,17 @@ public final class ComposeKey if (next < 0) return null; next = edges[next]; - char next_header = states[next]; + int next_header = states[next]; if (next_header == 0) // Enter a new intermediate state. return KeyValue.makeComposePending(String.valueOf(c), next, 0); - else if (next_header > 0) // Character final state. - return KeyValue.makeCharKey(next_header); - else // next_header is < 0, string final state. + else if (next_header == 0xFFFF) // String final state { int next_length = edges[next]; return KeyValue.makeStringKey( - new String(states, next + 1, next + next_length)); + new String(states, next + 1, next_length - 1)); } + else // Character final state. + return KeyValue.makeCharKey((char)next_header); } /** The state machine is comprised of two arrays. -- cgit v1.2.3