Package: catdoc
Version: 1:0.95-4
Tags: patch

This issue happens when running 'xls2csv' on XLS files containing international characters (mainly from the ISO-8859-1 or CP1252 sets) and when the default source charset is not apropriate to convert the characters.

You can reproduce it with the attached XLS file by running the command:

xls2csv -s cp1251 hungarian.xls

Details: the attached patch seems to fix the issue.

Attachment: hungarian.xls
Description: MS-Excel spreadsheet

diff --git a/src/xlsparse.c b/src/xlsparse.c
index cd8aa0e..2edeed5 100644
--- a/src/xlsparse.c
+++ b/src/xlsparse.c
@@ -573,8 +573,14 @@ unsigned char *copy_unicode_string (unsigned char **src, int fromSst,
 				check_charset(&source_csname,source_csname);	
 				/* fprintf(stderr,"charset=%s\n",source_csname);*/
 				source_charset=read_charset(source_csname);
-			}	
-			u=(unsigned short)to_unicode(source_charset,(unsigned char)*s);
+			}
+			if (codepage != 1200) {
+				u=(unsigned short)to_unicode(source_charset,(unsigned char)*s);
+			} else {
+				/* if charsize == 1 and codepage == 1200, then compression is used */
+				u = *s;
+			}
+
 			c=(unsigned char *)convert_char(u);
 		}
 		if (c != NULL) {

Reply via email to