MKI_TextIsUTF8 (Strings) Renamed in Version 2024.0

www.CAD6.com

C++ Syntax

bool

MKI_TextIsUTF8(

 const LPCSTR f_pszText );

 

Checks if a given 8-bit-character string seems to be a UTF-8 string or not. It does NOT check for a UTF-8 BOM!

 

Parameters

Text

[const LPCSTR] Address of the text to be checked.

 

Return Value

Returns true if the string seems to be a UTF-8 string, indicated by containing at least one UTF-8 encoded character and no invalid UTF-8 coding sequence. If false is returned, the string is either an ANSI string or a UTF-8 string without any encoding (i.e. using only characters in the range 0 to 127).

 

Comment

This check is not 100% safe, it may yield false positives since it's possible that a string was initially supposed to be handled as ANSI even though it contains at least one valid UTF-8 coding sequence by chance!

 

CAD6interface 2025.0 - Copyright 2025 Malz++Kassner® GmbH