mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
Fixed bug with iso2022jp locale (bug #18719)
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2007-04-25
|
||||
ChangeLog - 2007-05-02
|
||||
|
||||
|
||||
Version 0.2.5 (under dev!):
|
||||
* fixed bug with iso2022jp locale (bug #18719)
|
||||
* fixed string format bug when displaying string thru plugin script API
|
||||
* added /reconnect command (task #5448)
|
||||
* added "-all" option for /connect and /disconnect commands (task #6232)
|
||||
|
||||
@@ -55,6 +55,22 @@ utf8_init ()
|
||||
local_utf8 = (ascii_strcasecmp (local_charset, "UTF-8") == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8_has_8bits: return 1 if string has 8-bits chars, 0 if only 7-bits chars
|
||||
*/
|
||||
|
||||
int
|
||||
utf8_has_8bits (char *string)
|
||||
{
|
||||
while (string && string[0])
|
||||
{
|
||||
if (string[0] & 0x80)
|
||||
return 1;
|
||||
string++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8_is_valid: return 1 if UTF-8 string is valid, 0 otherwise
|
||||
* if error is not NULL, it's set with first non valid UTF-8
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
extern int local_utf8;
|
||||
|
||||
extern void utf8_init ();
|
||||
extern int utf8_has_8bits (char *);
|
||||
extern int utf8_is_valid (char *, char **);
|
||||
extern void utf8_normalize (char *, char);
|
||||
extern char *utf8_prev_char (char *, char *);
|
||||
|
||||
+15
-2
@@ -201,6 +201,7 @@ weechat_iconv (int from_utf8, char *from_code, char *to_code, char *string)
|
||||
#ifdef HAVE_ICONV
|
||||
iconv_t cd;
|
||||
char *inbuf, *ptr_inbuf, *ptr_outbuf, *next_char;
|
||||
char *ptr_inbuf_shift;
|
||||
int done;
|
||||
size_t err, inbytesleft, outbytesleft;
|
||||
|
||||
@@ -218,6 +219,7 @@ weechat_iconv (int from_utf8, char *from_code, char *to_code, char *string)
|
||||
outbytesleft = inbytesleft * 4;
|
||||
outbuf = (char *) malloc (outbytesleft + 2);
|
||||
ptr_outbuf = outbuf;
|
||||
ptr_inbuf_shift = NULL;
|
||||
done = 0;
|
||||
while (!done)
|
||||
{
|
||||
@@ -260,8 +262,19 @@ weechat_iconv (int from_utf8, char *from_code, char *to_code, char *string)
|
||||
}
|
||||
}
|
||||
else
|
||||
done = 1;
|
||||
{
|
||||
if (!ptr_inbuf_shift)
|
||||
{
|
||||
ptr_inbuf_shift = ptr_inbuf;
|
||||
ptr_inbuf = NULL;
|
||||
inbytesleft = 0;
|
||||
}
|
||||
else
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
if (ptr_inbuf_shift)
|
||||
ptr_inbuf = ptr_inbuf_shift;
|
||||
ptr_outbuf[0] = '\0';
|
||||
free (inbuf);
|
||||
iconv_close (cd);
|
||||
@@ -298,7 +311,7 @@ weechat_iconv_to_internal (char *charset, char *string)
|
||||
|
||||
if (input)
|
||||
{
|
||||
if (utf8_is_valid (input, NULL))
|
||||
if (utf8_has_8bits (input) && utf8_is_valid (input, NULL))
|
||||
return input;
|
||||
|
||||
output = weechat_iconv (0,
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2007-04-25
|
||||
ChangeLog - 2007-05-02
|
||||
|
||||
|
||||
Version 0.2.5 (under dev!):
|
||||
* fixed bug with iso2022jp locale (bug #18719)
|
||||
* fixed string format bug when displaying string thru plugin script API
|
||||
* added /reconnect command (task #5448)
|
||||
* added "-all" option for /connect and /disconnect commands (task #6232)
|
||||
|
||||
@@ -55,6 +55,22 @@ utf8_init ()
|
||||
local_utf8 = (ascii_strcasecmp (local_charset, "UTF-8") == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8_has_8bits: return 1 if string has 8-bits chars, 0 if only 7-bits chars
|
||||
*/
|
||||
|
||||
int
|
||||
utf8_has_8bits (char *string)
|
||||
{
|
||||
while (string && string[0])
|
||||
{
|
||||
if (string[0] & 0x80)
|
||||
return 1;
|
||||
string++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* utf8_is_valid: return 1 if UTF-8 string is valid, 0 otherwise
|
||||
* if error is not NULL, it's set with first non valid UTF-8
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
extern int local_utf8;
|
||||
|
||||
extern void utf8_init ();
|
||||
extern int utf8_has_8bits (char *);
|
||||
extern int utf8_is_valid (char *, char **);
|
||||
extern void utf8_normalize (char *, char);
|
||||
extern char *utf8_prev_char (char *, char *);
|
||||
|
||||
@@ -201,6 +201,7 @@ weechat_iconv (int from_utf8, char *from_code, char *to_code, char *string)
|
||||
#ifdef HAVE_ICONV
|
||||
iconv_t cd;
|
||||
char *inbuf, *ptr_inbuf, *ptr_outbuf, *next_char;
|
||||
char *ptr_inbuf_shift;
|
||||
int done;
|
||||
size_t err, inbytesleft, outbytesleft;
|
||||
|
||||
@@ -218,6 +219,7 @@ weechat_iconv (int from_utf8, char *from_code, char *to_code, char *string)
|
||||
outbytesleft = inbytesleft * 4;
|
||||
outbuf = (char *) malloc (outbytesleft + 2);
|
||||
ptr_outbuf = outbuf;
|
||||
ptr_inbuf_shift = NULL;
|
||||
done = 0;
|
||||
while (!done)
|
||||
{
|
||||
@@ -260,8 +262,19 @@ weechat_iconv (int from_utf8, char *from_code, char *to_code, char *string)
|
||||
}
|
||||
}
|
||||
else
|
||||
done = 1;
|
||||
{
|
||||
if (!ptr_inbuf_shift)
|
||||
{
|
||||
ptr_inbuf_shift = ptr_inbuf;
|
||||
ptr_inbuf = NULL;
|
||||
inbytesleft = 0;
|
||||
}
|
||||
else
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
if (ptr_inbuf_shift)
|
||||
ptr_inbuf = ptr_inbuf_shift;
|
||||
ptr_outbuf[0] = '\0';
|
||||
free (inbuf);
|
||||
iconv_close (cd);
|
||||
@@ -298,7 +311,7 @@ weechat_iconv_to_internal (char *charset, char *string)
|
||||
|
||||
if (input)
|
||||
{
|
||||
if (utf8_is_valid (input, NULL))
|
||||
if (utf8_has_8bits (input) && utf8_is_valid (input, NULL))
|
||||
return input;
|
||||
|
||||
output = weechat_iconv (0,
|
||||
|
||||
Reference in New Issue
Block a user