PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Equivalence between StringCompare and the comparison operators
  • Comparing the numeric values
  • Characters taken into account for the punctuation and the spaces
  • StingCompare function and UNICODE
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Compares two strings character by character:
  • according to the sequence of ASCII characters.
  • according to the alphabetical order.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 17 and later
This function is now available for the iPhone/iPad applications.
This function is now available for the Windows Phone applications.
New in version 17
This function is now available for the iPhone/iPad applications.
This function is now available for the Windows Phone applications.
This function is now available for the iPhone/iPad applications.
This function is now available for the Windows Phone applications.
Versions 18 and later
This function is now available in Android Widget mode.
This function is now available in Windows Store apps mode.
New in version 18
This function is now available in Android Widget mode.
This function is now available in Windows Store apps mode.
This function is now available in Android Widget mode.
This function is now available in Windows Store apps mode.
Versions 21 and later
This function is now available in Apple Watch mode.
This function is now available in Universal Windows 10 App mode.
New in version 21
This function is now available in Apple Watch mode.
This function is now available in Universal Windows 10 App mode.
This function is now available in Apple Watch mode.
This function is now available in Universal Windows 10 App mode.
Example
MyString1 is string = "Developing is fantastic"
MyString2 is string = "Developing is simple"
ResultCompare is int = StringCompare(MyString1, MyString2)
// ResultCompare = -1: the character 'f' comes before the character 's'
Syntax
<Result> = StringCompare(<First String> , <Second String> [, <Options>])
<Result>: Integer
  • 0 if the character strings are equal.
  • -1 if the characters found in <First String> are less than the characters found in <Second String> according to the sequence of ASCII characters or to the lexicographic order.
  • 1 if the characters found in <First String> are greater than the characters found in <Second String> according to the ASCII order or to the lexicographic order.
<First String>: Character string (with quotes)
Character string to compare.
<Second String>: Character string (with quotes)
Character string to compare.
<Options>: Optional constant (or combination of constants)
Comparison options:
ccNormal
(default value)
Standard comparison, similar to the operator ='.
ccLexicographicOrderCompare the character strings according to the lexicographic order (for example, the character 'é' is found between the characters 'e' and 'f').
WEBDEV - Browser codePHP This constant is not available.
ccRespectNumericComparison while taking into account the numeric characters found inside the strings (in this case, "10" comes after "9").
ccIgnoreAccentComparison while ignoring the accented characters.
WEBDEV - Browser code This constant is not available.
ccIgnoreCaseComparison while ignoring the case (uppercase/lowercase characters).
ccIgnoreSpaceComparison while ignoring the space characters found before and after the character strings to compare.
Versions 20 and later
ccIgnoreInsideSpace
New in version 20
ccIgnoreInsideSpace
ccIgnoreInsideSpace
Comparison while ignoring the space characters found inside the character strings to compare.
WEBDEV - Browser codeAndroidJavaPHP This constant is not available.
ccIgnorePonctuationAndSpaceComparison while ignoring the punctuation and the space characters (see the Notes for more details).
WEBDEV - Browser code This constant is not available.
Remarks

Equivalence between StringCompare and the comparison operators

  • = operator:
    The = operator is equivalent to the following code: StringCompare(<String1>, <String2>, ccNormal)
  • ~= operator:
    The ~= operator is equivalent to the following code: StringCompare(<String1>, <String2>, ccIgnoreCasse, + ccIgnoreAccent + ccIgnoreSpace)
    WEBDEV - Browser code This syntax is not available.
  • ~~ operator:
    The ~~ operator is equivalent to the following code: StringCompare(<String1>, <String2>, ccIgnoreCasse + ccIgnoreAccent + ccIgnorePonctuationAndSpace)
    WEBDEV - Browser code This syntax is not available.
  • Operator <, >, <= and >=:
    These operators are equivalent to the following code: StringCompare(<String1>, <String2>, ccLexicographicOrder)
    WEBDEV - Browser code This syntax is not available.
See the Comparison operators for more details.
Reports and QueriesWindowsLinuxAndroidWindows MobileJavaAjaxUser code (UMC)

Comparing the numeric values

The ccRespectNumeric constant performs the sort by taking into account the numeric value represented by digits and not just the alphabetical order of numbers.
Without the ccRespectNumeric constant, the strings below will be sorted in the following order: "string1", "string10", "string2"
With the ccRespectNumeric constant, the same strings will be sorted in this order: "string1", "string2", "string10"
Examples of comparison performed with and without the ccRespectNumeric constant:
Sorting strings containing digits without the ccRespectNumeric constantSorting strings containing digits with the ccRespectNumeric constant
000
000
001001
00901
011
010009
0909
19
10010
1110
911
Sorting strings containing digits without the ccRespectNumeric constantSorting strings containing digits with the ccRespectNumeric constant
10.00Aa7.00Aa
10.01Gh7.01Ba
10.50Ag7.01Dfe
11.00Aa7.50Fg
7.00Aa7.51Tga
7.01Ba8.00Aa
7.01Dfe8.01Gjk
7.50Fg8.01Ty
7.51Tga8.50Ze
8.00Aa9.00Aa
8.01Gjk9.80Er
8.01Ty9.99Zaaa
8.50Ze10.00Aa
9.00Aa10.01Gh
9.80Er10.50Ag
9.99Zaaa11.00Aa
WINDEVWEBDEV - Server codeReports and QueriesAndroidWindows MobileJavaPHPAjaxUser code (UMC)

Characters taken into account for the punctuation and the spaces

The characters taken into account for the punctuation and the spaces are supplied by the system. To get the list of these characters, write the following WLanguage code:
s is string
FOR i = 0 TO 255
IF Charact(i) <> StringFormat(Charact(i), ccIgnorePonctuationAndSpace) THEN
 s += Charact(i)
END
END
Info(s)
ToClipboard(s)
Reports and QueriesWindowsLinuxAndroidWindows MobileJavaPHPAjaxUser code (UMC)

StingCompare function and UNICODE

Some ANSI strings, some Unicode strings and some buffers can be used in the different parameters of the function (<First String> and <Second String>).
The following conversion rule is used for the Ansi systems (Windows or Linux):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • If the first condition is not fulfilled, if at least one of the strings in in Unicode format, all the strings are converted into Unicode and the operation is performed in Unicode (the conversion is performed with the current character set if necessary)
  • Otherwise, the operation is performed in Ansi.
The following conversion rule is used for the Unicode systems (Windows CE):
  • It at least one of the strings is a buffer, all the strings are converted into buffers and the operation is performed with buffers,
  • Otherwise, the operation is performed in Unicode.
  • The linguistic parameters used are defined during the call to ChangeCharset.
See Managing the UNICODE for more details.
Components
WINDEVWEBDEV - Server codeReports and Queries wd0vm.dll
Windows Mobile wp0vm.dll
WEBDEV - Browser code WDJS.DLL
Java wd0java.jar
Linux wd0vm.so
Android wd0android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment