DecodeString
Valid for: CANoe DE • CANoe:lite DE • CANoe4SW DE • CANoe4SW:lite DEFunction Syntax
Description
Decodes the byte array input from the encoding codepage to the current CAPL string encoding. The length of the decoded string depends on the given encoding. If the size of the output array outputSize is not sufficient to hold the decoded string and a terminating “\0”, the functions returns an error and the content of output is undefined. Characters that cannot be represented in the current encoding, are replaced with the best matching character, selected by the Windows functionWideCharToMultiByte.
Note:
- Unlike the
WideCharToMultiByteWindows function, the char array output is always terminated with “\0”. - The CAPL string encoding usually matches the encoding of the source file. When you create a file with the CAPL Browser, it will save the file in an encoding which matches the language settings of your computer and write the encoding in a special comment at the beginning of the file. If the source file is encoded in UTF-16 or if an include file has a different encoding than the source file, the CAPL string encoding will be UTF-8.
Parameters
- output: Target char array.
- outputSize: Size of the output array.
- input: The input string in encoding codepage, without BOM.
- codepage: Windows code page number for input. The include file Encoding.cin defines the following code pages:
- CP_UTF8
- CP_UTF16
- CP_LATIN1
- CP_SHIFT_JIS
Return Values
- 0: Success, the byte array output is valid.
- -1: Illegal character (e.g. illegal UTF8 code point).
- -2: Insufficient buffer space, output array is too small.
- -3: Internal error.