|
|
|
|
|
- What is Unicode?
- Unicode management
- Implicit conversions
Unicode in character strings
The Unicode format is an encoding system that assigns a unique number to each character: - This system uses a 16-bit encoding.
- This number can be read regardless of the platform, software or language used.
Unicode can take into account every writing system on the planet. Unicode is used: - for character strings
- for data files
- for controls that display data from character strings or data files.
To manage Unicode, WINDEV offers: - an option to define the string format at runtime in the project configuration description.
To change the string format in the current configuration:
- Display the project description window: in the "Project Explorer" pane, open the context menu for the "Configurations" option and select "Description".
- In the window that appears, select the "Unicode" tab and choose the desired mode: "Use ANSI strings at runtime" or "Use UNICODE strings at runtime".
- Unicode string type.
- conversion functions:
These functions convert ANSI characters to Unicode and vice versa. Character strings are automatically converted (see paragraph below).
| | AnsiToUnicode | Converts:- an ANSI string (Windows) to a UNICODE string.
- a buffer containing an ANSI string (Windows) to a buffer containing a UNICODE string.
| StringToUTF8 | Converts an ANSI or Unicode string to UTF-8. | UnicodeToAnsi | Converts:- a UNICODE string to ANSI (Windows).
- a buffer containing a UNICODE string to a buffer containing an ANSI string (Windows).
| UTF8ToString | Converts a string in UTF8 format into an ANSI or Unicode string. |
- functions to handle character strings:
| | Complete | Returns a character string of a specified length. | CompleteDir | Adds a backslash to the end of a string, if necessary. | ExtractString | Allows you to:- extract a substring from a string based on a specified string separator.
- search for substrings in a string based on a specified string separator.
| Left | Extracts the left part (i.e., the first characters) from a string or buffer. | Length | Returns:- the length of a string, i.e., the number of characters in the string (including spaces and binary zeros).
- the size of a buffer, i.e., the number of bytes in the buffer.
| Middle | Extracts: - a substring from a string starting at a specified position.
- part of a buffer starting at a specified position.
| NoAccent | Converts accented characters in a string to non-accented characters. | NoSpace | Returns a character string without the space characters: - from the left and right side of the initial string.
- within the string.
| Position | Finds the position of a specified string within another string. | PositionOccurrence | Finds the Xth position of a string within another string. | RepeatString | Concatenates N number of copies of the same specified string or buffer. | Replace | Replaces all occurrences of a specified substring in a string with another specified substring. | Reverse | Returns the character that corresponds to the difference between the ASCII code of a specific character in a string and 255. | Right | Extracts the last characters from a string or string buffer. | StringCompare | Compares two strings character by character:- according to the sequence of ASCII characters.
- according to the alphabetical order.
| StringCount | Calculates: - the number of occurrences of a specific character string (by respecting the search criteria) in another character string.
- the number of occurrences of a set of strings in an array.
| StringFormat | Formats a character string according to the selected options. | TypeVar | Identifies the type of an expression, a variable (during a call to a procedure for example) or a control. | Val | Returns the numeric value of a character string. |
- the use of operators for handling character strings:
- operators to iterate over character strings:
- the use of functions for handling text files:
| | fOpen | Opens an external file (ANSI or Unicode) to handle it programmatically. | fRead | Reads a block of bytes (characters) from an external file (ANSI or Unicode). | fReadLine | Reads a line from an external file (ANSI or Unicode). | fWrite | Writes a string to an external file (ANSI or Unicode). | fWriteLine | Writes a line to a text file (ANSI or Unicode). |
Implicit conversions Starting with version 12, conversions between ANSI and Unicode strings are implicit.. These conversions are performed using the current character set (defined with ChangeCharset). From version 15 onwards, Unicode character strings are automatically converted when one of the following types is assigned to an HFSQL field: Boolean, integer (all sizes, with or without sign), monetary, numeric or real. Use cases:
ResU is Unicode string = AnsiToUnicode("Test of a string")
ResU is Unicode string = "Test of a string"
Res is string
ResU is Unicode string
ResU = AnsiToUnicode(Res)
Res = UnicodeToAnsi(ResU)
ResU = Res
Res = ResU
Res is string
ResU is Unicode string
IF ResU <> AnsiToUnicode("") THEN ...
IF ResU <> AnsiToUnicode(Res) THEN ...
IF ResU <> "" THEN ...
IF ResU <> Res THEN...
nFil is int = fOpen("E:\temp\Unicode.txt", foRead + foUnicode)
ResU is Unicode string
ResU = fReadLine(nFile)
WHILE ResU <> EOT
Trace(ResU)
ResU = fReadLine(nFile)
END
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|