else if (c < ' ')
sprintf(k, "C-Chr-%c", c+64);
else
- sprintf(k, "Chr-%c", c);
+ sprintf(k, "Chr-%lc", c);
}
ci.key = buf;
* Unicode points. This particularly affects adding new strings to
* allocations.
* There is no guarantee that a byte string is UTF-8 though, so
- * We only adjust the length if we can find an end-of-code-point in
+ * We only adjust the length if we can find a start-of-code-point in
* the last 4 bytes. (longest UTF-8 encoding of 21bit unicode is 4 bytes).
+ * A start of codepoint starts with 0b0 or 0b11, not 0b10.
*/
static int text_round_len(char *text, int len)
{
/* The string at 'text' is *longer* than 'len', or
* at least text[len] is defined - it can be nul. If
- * len doesn't mark the end of a UTF-8 codepoint,
- * and there is an end marker in the previous 4 bytes,
+ * [len] isn't the start of a new codepoint, and there
+ * is a start marker in the previous 4 bytes,
* move back to there.
*/
int i = 0;
- while (i+1 < len && i <=4)
- if ((text[len-i] & 0xC0) == 0x80 &&
- (text[len-i-1] & 0x80) == 0x80)
- /* next byte is inside a UTF-8 code point, so this isn't a good
- * spot to end. Try further back */
+ while (i <= len && i <=4)
+ if ((text[len-i] & 0xC0) == 0x80)
+ /* next byte is inside a UTF-8 code point, so
+ * this isn't a good spot to end. Try further
+ * back */
i += 1;
else
return len-i;
}
key_add_range(m, "Chr- ", "Chr-~", &emacs_insert);
+ key_add_range(m, "Chr-\200", "Chr-\377\377\377\377", &emacs_insert);
key_add(m, "Tab", &emacs_insert_other);
key_add(m, "LF", &emacs_insert_other);
key_add(m, "Return", &emacs_insert_other);