[DUG] widestring woes, MBCS through tcp

Dennis Chuah dennis_cs_chuah at hotmail.com
Thu Nov 23 12:07:46 NZDT 2006


Why don't you use UTF-8.  There are Delphi functions to convert UTF-8 to 
widestring and vice versa.  Then you will not have any character encoding 
issues.

----- Original Message ----- 
From: "Phil Scadden" <p.scadden at gns.cri.nz>
To: <delphi at delphi.org.nz>
Sent: Thursday, November 23, 2006 10:17 AM
Subject: [DUG] widestring woes, MBCS through tcp


> Having some hassles with hebrew. I have tcp service (indy) that is reading
> data from database, sending it to custom tcp client for display. Problem
> when the text includes some hebrew.
>
> The display side needs to detect it has a MBCS. Looks at Ord of character
> in passed string. Okay.
>
> When I fetched from database with 
> ADOTable1.FieldbyName('Details').asstring
> then everything went well. I used iohander.writeln and readln to read the
> data in plain strings.
>
> Changed to ADOQuery1 instead.
> ADOQuery1.fieldbyname('Details').asstrings returns the string with all the
> hebrew characters converted to '?' (Ord = 63)
>
> if I go ord(ADOQUERY1.FieldByName('Details').aswidestring[183]) where
> 183 is position of hebrew character, I get say 1513. Good.
> now
> var teststr:Widestring
>
> teststr := ADOQUERY1.FieldByName('Details').aswidestring;
> ord(teststr[183]) = 63  !!!! WTF.
>
> Even assigneding to widestring is causing the characters to be converted
> to '?'
>
> BDS2006. I am lost here. what is going on??
>
> ----------------------------------------------------------
> Phil Scadden, Institute of Geological and Nuclear Sciences
> 764 Cumberland St, Private Bag 1930, Dunedin, New Zealand
> Ph +64 3 4799663, fax +64 3 477 5232
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
> 



More information about the Delphi mailing list