String comparisons in VO and Windows

Hi Igor,

> First, I use VO27 + W2KSP4 English, Ukraine (0x0422).
> Second, the problem is _chr(0) inside VO-string.
> Everything is OK for #clipper collation, but for #windows:

> c1:="ABC"+_chr(0)+"abcd"
> c2:="ABC"+_chr(0)+"1234"
> oCon:WriteLine( AsString(c1 == c2) )       // .F.
> oCon:WriteLine( AsString(c1 > c2) )         // .F.
> oCon:WriteLine( AsString(c1 < c2) )         // .F.

> And now surprize:
> c1:="ABC"+_chr(0)+"abcd"
> c2:="ABC"+_chr(0)+_chr(0)+"1234"
> oCon:WriteLine( AsString(c1 < c2) )         // .T. !!!!!
> oCon:WriteLine( AsString(c2 > c1) )         // .F.

> Ergo, for now (c1 < c2) != (c2 > c1)

There is of course an explanation for this:

When running with SetCollation(#Windows) VO uses the Windows API function
CompareString() to compare strings.

This function looks like:
int CompareString(          LCID Locale,
    DWORD dwCmpFlags,
    DWORD lpString1,
    DWORD cchCount1,
    DWORD lpString2,
    DWORD cchCount2
);

Remarks:


At startup the LocaleId is set to GetUserDefaultLCID() (in VO 2.0:
GetSystemDefaultLCID)
At this moment you can't change this setting.

For VO 2.7a we have added two runtime functions:

FUNCTION SetAppLocaleID(DWORD uiNewLocale) as DWORD
FUNCTION GetAppLocaleID() as DWORD

These functions allow you to change and retrieve the Locale used by the
Runtime from within your code.

The dwCmpFlags is set to SORT_STRINGSORT and can be set using the
SetWinCompFlags() function.

For Case-insensitive comparisons VO adds the NORM_IGNORECASE value to
dwCmpFlags.

CompareString may return EQUAL when strings are NOT binary equal. From the
CompareStrng Docs:

> Notice that if the return value is CSTR_EQUAL, the two strings are "equal"
> in the collation sense, though not necessarily identical.


When you are running with SetCollation(#Clipper) VO will use the character
tables in the Nation Module for string comparisons. This should return the
correct results with binary data.



--
Robert van der Hulst
AKA Mr. Data
Vo2Jet & Vo2Ado Support
www.sas-software.nl
mrdataREMOVE@sas-software.com
Commentaar van anderen:
ChristianLouboutin op 17-8-2010 om 4:49
Christian Louboutin Shoes, Christian Louboutin, Christian Louboutin Shoes, Wedding Shoes, Wedding Shoes, Louboutin Shoes, Christian Louboutin Discount copies of the mirror, so the angel of the practical activities of customers who activities. Christian Louboutin Evening, Manolo Blahnik Shoes, Christian, Louboutin, Christian Louboutin Sale, Louboutin Sale, Cheap Christian Louboutin Can you from your shoes, you give yourself into chargeless travel and bear your lifetime. Christian Louboutin Boots, Christian Louboutin Pumps, Christian Louboutin Sandals, Christian Louboutin Flats, Christian Louboutin Wedges, Christian Louboutin Sandals Do you agree to accept and hear the cases angled heel shoes forward or abstract, tear, buttons, and destruction, and the ability to reduce greenhouse gas emissions, it is exactly like daydreaming and shoes. Yves Saint Laurent Shoes, Christian Louboutin Boots, Manolo Blahnik Shoes, Yves Saint Laurent Boots, Miu Miu Shoes, Christian Dior Shoes this is an extra brand and shoes. However, you will never accept the amorous Louboutin christians through brand. Christian Louboutin Flats, Christian, Herve Leger V Neck Dress, Herve Leger Bandage Dress, Herve Leger Dress, Herve Leger V Neck Dress You can visit in your configuration of the life of their shoes were forgiven a brace, air brief you accept defeat them later anniversary, they are careful bag dust, shoe box that you have to go.
Geef feedback:

CAPTCHA image
Vul de bovenstaande code hieronder in
Verzend Commentaar