Syntax
| string = stringclassobject.FromUTF8
|
|---|---|
Description
| Decodes the contents of the StringClass instance, interpreting it as a UTF-8 byte sequence, and returns the resulting text in the standard Windows-1252 (ANSI) encoding used internally by Tradium Basic Script and CCL.
fromUTF8 is the inverse of toUTF8 and is intended for situations where text has been received from an external source in UTF-8 form — such as the body of a REST API response, the contents of a file written by a modern editor, an XML or JSON payload, or output from another platform — and must be brought back into the native string representation before it can be used in further script logic, displayed in a dialog, written to a database field, or compared with literal strings.
Conversion is performed via the Windows API functions MultiByteToWideChar followed by WideCharToMultiByte, which guarantees correct handling of all multi-byte sequences, including the cp1252-overlap range (accented Latin characters such as é, è, ü, ñ, ç) and the three-byte euro sign (€). The contents of the StringClass instance itself are not modified; fromUTF8 only returns the decoded result. Code points that exist in UTF-8 but have no representation in Windows-1252 — for example Cyrillic, Greek, Asian or Arabic characters — are replaced with a question mark in the result, in line with the standard WideCharToMultiByte fallback behaviour.
When the input is already plain ASCII or a Windows-1252 string without UTF-8 byte sequences, fromUTF8 returns the buffer unchanged. To verify whether the buffer is actually UTF-8 encoded before calling fromUTF8, use the .isUTF8 method. In most cases the toString method is the more convenient choice, as it inspects the buffer with isUTF8 and only invokes fromUTF8 when UTF-8 encoding is detected, otherwise returning the contents as-is.
|
See Also
| |
Example
| Sub Main |