Page 1 of 1

XLSReadWriteII 4 fails to handle Unicode in Delphi7?

Posted: Wed Oct 29, 2008 8:20 am
by jz
Hi there,
just a bug report.
Testing environment:
1. windows vista, locale : English (united states)
2. Delphi 7 professional
3. XLSReadWriteII 4

I wrote a simple program to read a content from an Excel file (excel 97--2003). The excel files contains traditional Chinese character. But all I got is simply the question mark: '?'.

Here is what I did:
opened the excel file, started loading the content of the file, in the debug mode I found that the value I obtained using function calls like AsString, AsWideString were all '?', the XLSReadWriteII 4 has not done the correct parsing..

One possible solution is to change the system locale to Chinese but the rigid development requirement is that the locale must be English so let's forget about this solution. Any suggestion will be greately appreciated!

Thanks in advance.

for your testing purpose, you can place this chinese sentence in an excel file and try to read it:
便利超商及麵包店,針對統一麵包所生產的土司

Posted: Wed Oct 29, 2008 5:01 pm
by larsa
Hello

XLSReadWriteII handles unicode characters correct, and always uses the WideString type. But please note that all Delphi versions prior to D2009 don't have any support for displaying unicode characters. All windows controls (TEdit, TListBox etc) are all single byte, and you must convert unicode strings to single byte strings using correct codepage. If you have an Excel file and want to see how XLSReadWriteII interprets the text, you can download the XLSSpreadSheet compiled demo from our site.

Posted: Thu Oct 30, 2008 2:37 am
by jz
larsa wrote:Hello

XLSReadWriteII handles unicode characters correct, and always uses the WideString type. But please note that all Delphi versions prior to D2009 don't have any support for displaying unicode characters. All windows controls (TEdit, TListBox etc) are all single byte, and you must convert unicode strings to single byte strings using correct codepage. If you have an Excel file and want to see how XLSReadWriteII interprets the text, you can download the XLSSpreadSheet compiled demo from our site.
Thank you larsa for your reply.
But what I meant was: I got all '?' immediately after calling XLSReadWriteII 4's AsString (or AsWideString) method. I did this in the debug mode, using the Watch List in Delphi. That means, the value returned from the XLSReadWriteII api is '?' already, that is the problem.

Since my system locale is English, it cannot display some unicode like Chinese character properly. But the expected return value from XLSReadWriteII should be some 'strange symbols' rather than '?'.

Posted: Thu Oct 30, 2008 6:22 am
by larsa
Hello

Are you sure that XLSReadWriteII returns the character "?" ? Have you checked that the hex value for the character is 3F? More likely is that D7
displays a question mark for any non-ascii characters.

Posted: Fri Oct 31, 2008 3:28 am
by jz
thanks, problem solved.