Fixed a bug where tab-complete didn't worked with utf8/big5 multibyte characters properly

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4229 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Valentin Batz 2006-01-29 22:37:24 +00:00 committed by vb
commit 0d10e2cc06
5 changed files with 66 additions and 6 deletions

View file

@ -182,6 +182,24 @@ void utf16_to_utf8(const unichar *str, char *out)
*out = '\0';
}
void utf16_to_utf8_with_pos(const unichar *str, int spos, char *out, int *opos)
{
int len;
const unichar *sstart = str;
char *ostart = out;
*opos = 0;
while (*str != '\0') {
len = utf16_char_to_utf8(*str, out);
out += len;
str++;
if(str - sstart == spos)
*opos = out - ostart;
}
*out = '\0';
}
static const unichar wcc[] = {
0x0, 0x300, 0x34F, 0x360, 0x363, 0x483, 0x487, 0x488, 0x48A, 0x591,
0x5A2, 0x5A3, 0x5BA, 0x5BB, 0x5BE, 0x5BF, 0x5C0, 0x5C1, 0x5C3, 0x5C4,

View file

@ -18,6 +18,10 @@ int utf16_char_to_utf8(unichar c, char *outbuf);
Make sure out is at least 6 x length of str. */
void utf16_to_utf8(const unichar *str, char *out);
/* unichar -> UTF-8 string with position transformed. The NUL is copied as well.
Make sure out is at least 6 x length of str. */
void utf16_to_utf8_with_pos(const unichar *str, int spos, char *out, int *opos);
/* XXX I didn't check the encoding range of big5+. This is standard big5. */
#define is_big5_los(lo) (0x40 <= (lo) && (lo) <= 0x7E) /* standard */
#define is_big5_lox(lo) (0x80 <= (lo) && (lo) <= 0xFE) /* extended */