Re: [gnumeric-list][PATCH - new version] handle unicode and codepagesfor Import/Export of Excel files
- From: gnumeric-list-admin gnome org
- To: gnumeric-list gnome org
- Subject: Re: [gnumeric-list][PATCH - new version] handle unicode and codepagesfor Import/Export of Excel files
- Date: Wed, 14 Mar 2001 19:26:11 -0500
It is too close to a release to try something like this.
I need more time to consider and test it. Possibly after release.
On Tue, Mar 13, 2001 at 05:02:50PM +0400, gnumeric-list-admin gnome org wrote:
@@ -587,12 +594,23 @@
ans->hidden = MS_BIFF_H_VISIBLE;
break;
}
+#if 0
if (ver == MS_BIFF_V8) {
- int slen = MS_OLE_GET_GUINT16 (q->data + 6);
+ int slen = MS_OLE_GET_GUINT16 (q->data + 6);
ans->name = biff_get_text (q->data + 8, slen, NULL);
- } else {
+ } else
+#endif
+ {
+ /*
+ * there are test files produced by non-latin1 Excel (e.g.
+ * russian version) that prove that branch above is
+ * incorrect. It seems test files that insured author of branch
+ * above were produced by latin1 version of Excel -
+ * in that case q->data[7] is always 0, so it can be attributed
+ * to length of sheet name or to the string header.
+ * - Vlad Harchev <hvv hippo ru>
+ */
int slen = MS_OLE_GET_GUINT8 (q->data + 6);
-
ans->name = biff_get_text (q->data + 7, slen, NULL);
}
This is one of the few areas that the XL file format docs are very
clear on. I'll need to study this in more detail before it can go
in.
+static char*
+get_locale_charset_name()
+{
+#ifndef HAVE_ICONV
+ return "";
+#else
+ static char* charset = NULL;
+
+ if (charset)
+ return charset;
+
+#ifdef _NL_CTYPE_CODESET_NAME
+ charset = nl_langinfo (_NL_CTYPE_CODESET_NAME);
+#elif defined(CODESET)
+ charset = nl_langinfo (CODESET);
+#elif
#else
+ {
+ char* locale = setlocale(LC_CTYPE,NULL);
+ char* tmp = strchr(locale,'.');
+ if (tmp)
+ charset = tmp+1;
+ }
+#endif
+ if (!charset)
+ charset = "ISO-8859-1";
+ charset = g_strdup(charset);
+ return charset;
^^^^^
This seems like a recipe for problems.
Is the caller is responsible for freeing the string ? What ensures
that the value will be valid ? If that is the case then the
!HAVE_ICONV case will fail.
+#endif
+}
+guint
+excel_iconv_win_codepage()
+{
+ char* lang = NULL;
+ static guint codepage = 0;
+ char* env_lang;
+
+ if (codepage)
+ return codepage;
+
+ /* the code below is executed only once */
If it is called only once why leak ?
+ if (env_lang = getenv("WINDOWS_LANGUAGE"))
+ lang = env_lang; /* just for flexibility */
+ else {
+ char* locale = setlocale(LC_CTYPE,NULL);
+ char* lang_sep = strchr(locale,'_');
+ if (lang_sep)
+ lang = g_strndup(locale,lang_sep-locale);
+ else
+ lang = locale;
+ }
+ lang = g_strdup(lang);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]