ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / 
  • Types of character strings
  • Special case
  • Fixed string and ASCIIZ string
  • Processing fixed strings
  • extension attribute
  • String interpolation (dynamic string building)
  • Notes
  • Default value
  • Passing a character string as a parameter to a procedure
  • Using quotes in a character string
  • Comparing the different types of strings available in WINDEV and in WINDEV Mobile
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Types of character strings
WLanguage supports different types of strings.
1. The most common types are as follows:
  • Character
Character coded on 1, 2 or 4 bytes according to the management mode of character strings and the runtime platform.
  • In Windows:
    • in Ansi, a character is encoded on 1 byte,
    • in Unicode, a character is encoded on 2 bytes.
  • In Linux:
    • in Ansi, a character is encoded on 1 byte,
    • in Unicode, a character is encoded on 4 bytes.
  • In iOS, in Unicode, a character is coded on 4 bytes.
When a character is empty, its value corresponds to Charact(0).
WINDEV Remark:
  • If the current configuration uses ANSI strings at runtime, the Character variables will be ANSI characters (default behavior).
  • If the current configuration uses Unicode strings at runtime, the Character variables will be Unicode characters.
Reminder: To change the string format in the current configuration:
  1. Open the project description window: on the "Project" tab, in the "Project" group, click "Description".
  2. In the "Project" tab, click "Configuration description".
  3. In the window that appears, go to the "Unicode" tab and select the desired mode.
Universal Windows 10 AppJava The Character type is not supported. It is replaced with the String type.
  • Ansi string
Variable-length string containing ANSI characters only.
This format is required to handle:
  • XML files
  • RTF files
  • PDF files
  • functions that use UTF8 format, etc.
  • Unicode string
Variable-length string containing UNICODE characters only.
WINDEV In a configuration that uses Ansi strings at runtime, this type of string can be returned by AnsiToUnicode or by one of the functions for managing Unicode strings.
For more details, see Unicode management.
WINDEV This type of character string is used by default if the current configuration uses Unicode strings at runtime.
Universal Windows 10 AppJava This type of character string is not supported. It is replaced with the String type.
  • String
Variable-length string.

The "string" type is specific to the WLanguage. With this type, there is no need to declare the length of the string. It can change when the variable is used.
WINDEV Remark:
  • If the current configuration uses ANSI strings at runtime, the String variables will be ANSI strings (default behavior).
  • If the current configuration uses Unicode strings at runtime, the String variables will be Unicode strings.
Reminder: To change the string format in the current configuration:
  1. Open the project description window: on the "Project" tab, in the "Project" group, click "Description".
  2. In the "Project" tab, click "Configuration description".
  3. In the window that appears, go to the "Unicode" tab and select the desired mode.
Universal Windows 10 App This type of character string is in Unicode format.
  • Buffer
Binary memory area. Used to write a code that can be shared between WINDEV and WINDEV Mobile regarding the use of raw data. For more details, see the "Buffer" type.
Universal Windows 10 App The Buffer type is not supported.
2. Other types of character strings can also be used:
  • String on
Fixed-length string, ending with a binary 0 (as in C). The specified size is the maximum number of characters in the string.
This type of character string is used to create compatible WINDEV/WINDEV Mobile code when calling APIs from both platforms.
WINDEV This type of character string is in ANSI format.
  • ASCIIZ string on
String ending with a binary 0 (as in C).
The length of an ASCIIZ string cannot exceed 2 GB. The length given to the ASCIIZ string must be equal to its current length plus 1 (for the binary zero).
Universal Windows 10 AppJava The ASCIIZ String type is not supported. It is replaced with the String type.
  • Fixed string on
Fixed-length string.
A fixed-length string cannot exceed 2 GB. The character string is completed:
  • with 0 if the variable is not assigned yet.
  • with space characters if necessary if the variable is assigned (similar to the "string" type of Basic).
Universal Windows 10 AppJava The Fixed String type is not supported. It is replaced with the String type.
  • Pascal string on
String preceded by a byte that specifies the length (similar to Pascal). This byte is not accessible. For example string[1] represents the first character of the string and not its length.
The length of a Pascal string cannot exceed 255 characters. The length given to the Pascal string must be equal to the length of the string.
Universal Windows 10 AppJava The Pascal String type is not supported. It is replaced with the String type.
  • Unicode string on
Fixed-length string containing UNICODE characters only.
Universal Windows 10 AppJava This type of character string is not supported. It is replaced with the String type.
Remarks:
  • The "String on" type must be used to send input/output parameters to a Windows API.
  • All the advanced types (other than "String") are available for compatibility with the other programming languages (Turbo Pascal Windows, C, Visual Basic Windows, etc.) or to receive the result of a Windows API.
  • WINDEV Mobile and WINDEV do not support the same types of character strings. For more details on the different types of character strings available, see the Notes section.
Special case
WINDEVWindowsUser code (UMC)

Fixed string and ASCIIZ string

  • When declaring an ASCIIZ string or a fixed string, the necessary memory is immediately allocated. Therefore, you should avoid using very large strings.
  • The fixed string is filled with space characters. The initialization and assignment of a large string (several hundreds of kB) may take quite a long time.
WINDEVWindowsUniversal Windows 10 AppJava

Processing fixed strings

The fixed strings are not available in Java. They are replaced with the String type at runtime.
However, Complete can be used on a String variable:
MyString is string
MyString = Complète("Test", 10)
// Equivalent to
// MyString is fixed string on 10 characters
// MyString = "Test"

<uindetectable> extension attribute

The <undetectable> extension attribute obfuscates the value of a string stored in memory (for example, in a memory dump file).
By default, (if the <undetectable> extension attribute is not specified), all characters assigned to a String variable are visible in a memory dump file. These characters appear along with all the data in the dump file: this makes it impossible to determine what the string looks like, where it starts and where it ends.

The <undetectable> attribute obfuscates the value stored in memory. The value of the string cannot be determined based on the visible characters in the dump file.
This extension attribute is particularly useful to store a username or password in memory, to pass a password to HPass, or to connect to a database.
Example:
MyStringInMemory is string <undetectable>
MyStringInMemory = "Password"
Remarks:
  • Using the <undetectable> extension attribute can slow down the application. It should only be used on strings that require that attribute.
  • The <undetectable> extension attribute is not available for fixed-length strings.
String interpolation (dynamic string building)
String interpolation consists in combining variables (or expressions) and strings. To do so, WLanguage features:
  • A specific option in the "Compilation" tab of the project description window: Allow "[% %]" in strings.
  • A specific syntax:
    [%VariableName or Expression%]
    For example:
    // Ask for customer confirmation
    IF YesNo(Yes, "Do you confirm the creation of customer [%sCustomerName%]") = No THEN
    RETURN
    END
Remarks:
  • If the option is not checked in the "Compilation" tab of the project description window, the string appears as it is: the name of the variable (or expression) appears in the string.
  • Use "-%" before the "[% %]" characters to prevent them from being interpreted. Some WLanguage functions require this specific syntax. Example:
    grTooltip(GR_Deadline, grTooltipFormat, "[%CATEGORY%]" + CR + CR+ "[%VALUE%]" + " H")
    becomes
    grTooltip(GR_Deadline, grTooltipFormat, -%"[%CATEGORY%]" + CR + CR + -%"[%VALUE%]" + " H")
  • When translating this type of strings, the name of the variable (or expression) inside [% %] must not be changed. However, you can move the [%VariableName or Expression%] tag within the string.
Notes

Default value

  • A "String" or "String on" variable that is declared but not initialized corresponds to an empty string ("").
  • A "Buffer" variable that is declared but not initialized is empty.
  • A "Buffer on" variable that is declared but not initialized is filled with 0.

Passing a character string as a parameter to a procedure

A "String" variable can be passed as parameter to a procedure.
Caution: If the variable has a fixed length, you must remove spaces. For example:
MyString is string
MyString = "WINDEV is great"
// Delete spaces from MyString
MyString = NoSpace(MyString)
CountLetter(MyString)
// CountLetter is a procedure

Using quotes in a character string

To use the quote character in a character string, this character must be repeated twice.
For example:
MyString is string
MyString = "The ""General conditions"" option must be checked"
Info(MyString)
// Displays: The "General conditions" option must be checked
WINDEVWindowsUser code (UMC)

Comparing the different types of strings available in WINDEV and in WINDEV Mobile

WINDEV/WEBDEV
String format
WINDEV Mobile
String format
StringANSIUnicode
CharacterANSIUnicode
ASCIIZ string onANSI string of N charactersnot available
Fixed string onANSI string of N charactersnot available
Pascal string onANSI string of N charactersnot available
Unicode stringUnicodeUnicode
BufferBinaryBinary
String onANSI string of N charactersUnicode string of N characters
Unicode string onUnicode string of N charactersUnicode string of N characters
Buffer onBinary memo of N bytesBinary memo of N bytes
Related Examples:
Different types of strings Unit examples (WINDEV): Different types of strings
[ + ] Using the different types of strings available in WINDEV.
The specific features of each type are presented in details.
Types used:
- "Standard" string
- UNICODE string
- Fixed string
- Pascal String
- ASCIIZ String
- Buffer type
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/06/2023

Send a report | Local help