|
- Types of character strings
- Special case
- Fixed string and ASCIIZ string
- Processing fixed strings
- 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
Types of character strings WLanguage proposes different types of character strings. 1. The most common types are as folllows: | | | Character coded on 1, 2 or 4 bytes according to the management mode of character strings and the runtime platform.- In Windows:
- in Ansi mode, a character is coded on 1 byte,
- in Unicode mode, a character is coded on 2 bytes.
- In Linux:
- in Ansi mode, a character is coded on 1 byte,
- in Unicode mode, a character is coded 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).
Versions 17 and later New in version 17 | Versions 17 and laterAnsi string New in version 17Ansi string Ansi string
| Dynamic-size string containing characters in ANSI format only. This format is required to handle: - XML files
- RTF files
- PDF files
- functions that use UTF8 format, etc.
| | Dynamic-size string containing characters in UNICODE format only. Versions 17 and later New in version 17 | | Dynamic-size string.
The "string" type is specific to the WLanguage. With this type, there is no need to declare the length of the string. This one can freely change when using the variable. Versions 17 and later New in version 17 | | Binary memory zone. Used to write a code that can be shared between WINDEV and WINDEV Mobile regarding the use of raw data. See The "Buffer" type for more details. | 2. Other types of character strings can also be used:
| | | Fixed-length string, ending with a binary 0 (as in C). The specified size corresponds to 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. | | String ending with a binary 0 (as in C). The size 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). | | Fixed-length string. The size of a fixed 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).
| | String preceded by a byte that specifies the length (like in 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. | | Fixed-length string containing characters in UNICODE format. | 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 propose the same types of character strings. For more details on the different types of character strings available, see the Notes section.
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: The space characters must be deleted if the variable is a fixed-length variable. 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
Related Examples:
|
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
|
This page is also available for…
|
|
|
| |
| Click [Add] to post a comment |
|
| |
|
| |
| |
| |
| |
| |
| |
| | |
| |