From: John Darrington Date: Sun, 17 Feb 2013 10:28:52 +0000 (+0100) Subject: Added a warning if gnumeric files are not UTF8. Then blidly assume that they are. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cabf360fe343cb03b99f2d6e498f2ee557b5852;p=pspp Added a warning if gnumeric files are not UTF8. Then blidly assume that they are. --- diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index 6cb620d8f9..657c6d4a50 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -87,7 +87,8 @@ enum reader_state struct sheet_detail { - xmlChar *name; + /* The name of the sheet (utf8 encoding) */ + char *name; int start_col; int stop_col; @@ -138,13 +139,14 @@ gnumeric_get_sheet_name (struct spreadsheet *s, int n) struct gnumeric_reader *gr = (struct gnumeric_reader *) s; assert (n < s->n_sheets); - return gr->sheets[n].name; // Kludge: Assumes the encoding is utf8 + return gr->sheets[n].name; } static void process_node (struct gnumeric_reader *r); + char * gnumeric_get_sheet_range (struct spreadsheet *s, int n) { @@ -241,7 +243,7 @@ process_node (struct gnumeric_reader *r) } else if (XML_READER_TYPE_TEXT == r->node_type) { - r->sheets [r->spreadsheet.n_sheets - 1].name = xmlTextReaderValue (r->xtr); + r->sheets [r->spreadsheet.n_sheets - 1].name = CHAR_CAST (char *, xmlTextReaderValue (r->xtr)); } break; @@ -512,6 +514,22 @@ gnumeric_reopen (struct gnumeric_reader *r, const char *filename, bool show_erro r->spreadsheet.type = SPREADSHEET_GNUMERIC; + if (show_errors) + { + const xmlChar *enc = xmlTextReaderConstEncoding (r->xtr); + xmlCharEncoding xce = xmlParseCharEncoding (CHAR_CAST (const char *, enc)); + + if ( XML_CHAR_ENCODING_UTF8 != xce) + { + /* I have been told that ALL gnumeric files are UTF8 encoded. If that is correct, this + can never happen. */ + msg (MW, _("The gnumeric file `%s' is encoded as %s instead of the usual UTF-8 encoding. " + "Any non-ascii characters will be incorrectly imported."), + r->spreadsheet.file_name, + enc); + } + } + return r; }