Re: GTK2: Character conversion problem...
- From: Mohammed Sameer <Uniball gmx net>
- To: gtk-app-devel-list gnome org
- Subject: Re: GTK2: Character conversion problem...
- Date: 28 Jul 2002 17:50:23 +0300
On Sat, 2002-07-27 at 23:47, André wrote:
Scott Barron wrote:
On Sat, Jul 27, 2002 at 07:40:30PM +0200, Janus N. Tøndering wrote:
what if i'm loading a 64Kb, or more, file and have to convert it? what's
the best way?
thank's
andrew
Ok i'll tell you what i did when i was programing a text editor
we have 3 encodings for arabic: iso encoding, windows encoding, UTF-8
encoding
int encoding = 1 if the user wants to assume that the iso encoding'll be
used by default
suppose we have a NULL terminated string stored in a variable
gchar *buf;
gboolean x;
x = g_utf8_validate (buf, -1, NULL);
if (x != TRUE)
{
/* not utf-8 encoding: handle according to "encoding" */
gchar *utf_buf;
if (encoding == 1)
{ /* iso encoding */
utf_buf =
g_convert (buf, size, "UTF-8", "ISO_8859-6",NULL,NULL, NULL);
}
else
{ /* assume cp1256 */
utf_buf = g_convert (buf, size,"UTF-8", "WINDOWS-1256",NULL,NULL, NULL);
}
g_utf8_validate (utf_buf, -1, NULL);
g_assert (g_utf8_validate (utf_buf, -1, NULL));
gtk_text_buffer_insert (buffer, &iter, utf_buf, -1);
}
else
{
g_assert (g_utf8_validate (buf, -1, NULL));
gtk_text_buffer_insert (buffer, &iter, buf, -1);
}
got it ??
sure sometimes you'll open a file as windows encoding and it might be
iso but in that case i've added a menu to allow the user to change the
encoding
--
----------------
-- Uniball @ DALnet
Linux registered user # 224950
ICQ # 58475622
With Great Power, Comes Great Responsibilities.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]