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.nlmrdataREMOVE@sas-software.com