Re: UTF-8 warnings
- From: Vladimir Nadvornik <nadvornik suse cz>
- To: Leonard den Ottolander <leonard den ottolander nl>
- Cc: MC Devel <mc-devel gnome org>
- Subject: Re: UTF-8 warnings
- Date: Tue, 2 Nov 2004 16:40:53 +0100
On Tuesday 02 November 2004 16:28, Leonard den Ottolander wrote:
> Also 1 "discard qualifier" warning in help.c. But "Unconsting" p in
> help_show() does not fix this as p points to const char* paint_start.
> Introducing a (redundant) cast on the call of SLsmg_write_nchars() in
> the utf8-help patch. This should actually be fixed in slang.
>
This version of the patch compiles without warning.
--
Vladimir Nadvornik
developer
---------------------------------------------------------------------
SuSE CR, s.r.o. e-mail: nadvornik suse cz
Drahobejlova 27 tel:+420 2 9654 2373
190 00 Praha 9 fax:+420 2 9654 2374
Ceska republika http://www.suse.cz
--- src/help.c
+++ src/help.c
@@ -447,8 +447,22 @@
#else
SLsmg_draw_object (h->y + line + 2, h->x + col + 2, c);
#endif
+ } else {
+#ifdef UTF8
+ if (SLsmg_Is_Unicode) {
+ int len;
+ mbstate_t mbs;
+ wchar_t wc;
+ memset (&mbs, 0, sizeof (mbs));
+ len = mbrtowc(&wc, p, MB_CUR_MAX, &mbs);
+ if (len <= 0) len = 1; /* skip broken multibyte chars */
+
+ SLsmg_write_char(wc);
+ p += len - 1;
} else
+#endif
addch (c);
+ }
col++;
break;
}
@@ -770,6 +783,12 @@
message (1, MSG_ERROR, _(" Cannot open file %s \n %s "), filename ? filename : hlpfile,
unix_error_string (errno));
}
+ else
+ {
+ char *conv = utf8_to_local(data);
+ g_free(data);
+ data = conv;
+ }
if (!filename)
g_free (hlpfile);
--- src/util.h
+++ src/util.h
@@ -92,6 +92,8 @@
int mbstrlen (const char *);
wchar_t *mbstr_to_wchar (const char *);
char *wchar_to_mbstr (const wchar_t *);
+char *utf8_to_local(char *str);
+
#define MAX_I18NTIMELENGTH 14
#define MIN_I18NTIMELENGTH 10
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]