Remove internal utf8 functions in favour of glib ones.

git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4958 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Emanuele Giaquinta 2008-12-09 11:59:16 +00:00 committed by exg
commit d71aea5b2b
3 changed files with 19 additions and 92 deletions

View file

@ -24,67 +24,3 @@
#include "module.h"
int strlen_utf8(const char *str)
{
const unsigned char *p = (const unsigned char *) str;
int len;
unichar chr_r;
len = 0;
while (*p != '\0') {
chr_r = g_utf8_get_char_validated(p, -1);
if (chr_r & 0x80000000)
break;
len++;
p = g_utf8_next_char(p);
}
return len;
}
void utf8_to_utf16(const char *str, unichar *out)
{
const unsigned char *p = (const unsigned char *) str;
unichar result;
while (*p != '\0') {
result = g_utf8_get_char_validated(p, -1);
if (result & 0x80000000)
break;
p = g_utf8_next_char(p);
*out++ = result;
}
*out = '\0';
}
void utf16_to_utf8(const unichar *str, char *out)
{
int len;
while (*str != '\0') {
len = g_unichar_to_utf8(*str, out);
out += len;
str++;
}
*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 = g_unichar_to_utf8(*str, out);
out += len;
str++;
if(str - sstart == spos)
*opos = out - ostart;
}
*out = '\0';
}

View file

@ -1,20 +1,6 @@
#ifndef __UTF8_H
#define __UTF8_H
/* Returns length of UTF8 string */
int strlen_utf8(const char *str);
/* UTF-8 -> unichar string. The NUL is copied as well. */
void utf8_to_utf16(const char *str, unichar *out);
/* unichar -> UTF-8 string. The NUL is copied as well.
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 */