MKI_ConvertAutoToUTF16 (Strings) New in Version 2024.0

www.CAD6.com

C++ Syntax

bool

MKI_ConvertAutoToUTF16(

 const LPCSTR f_pszSource,

 LPWSTR f_pszDestin,

 const size_t f_unMaxSize );

 

 template <size_t f_unSize> bool

 MKI_ConvertAutoToUTF16(

         const LPCSTR f_pszSource,

         wchar_t (&f_rDestin)[f_unSize] );

 

Converts a text depending on its content either from Ansi encoding or from UTF-8 encoding to a UTF-16 Unicode text. The source encoding is determined by means of MKI_TextIsUTF8().

 

Please note that using Unicode characters in the range above 0x0000ffff can result in unexpected behavior since texts are always parsed one character at a time.

 

Parameters

Source

[const LPCSTR] Address of the source text, either in Ansi or UTF-8 encoding.

CharNum

[const size_t] Maximum number of characters of the source text to convert (not including any terminating '\0' character). If CharNum is not stated or the source text is shorter, it will be converted completely.

Destin

[LPWSTR] Pointer to or [wchar_t[]&] Reference to a UTF-16 character string that shall receive the converted text with a fixed maximum length.

MaxSize

[const size_t] Maximum allowed length of the destination text in UTF-16 characters including the terminating '\0' character.

 

Return Value

Returns true if the conversion was successful and the resulting string fit into the buffer. If false is returned since the buffer was too small, as many characters as possible were already converted and terminated by a '\0' character.

 

Comment

The resulting text will always be terminated with a '\0' character if the buffer size is at least 1, even if false is returned! The text may, however, be truncated.

 

CAD6interface 2025.0 - Copyright 2025 Malz++Kassner® GmbH