Checks if a file contains valid UTF-8 characters.
Public Declare Function CNV_CheckUTF8File Lib "diCrPKI.dll" (ByVal strFileName As String) As Long
nLen = CNV_CheckUTF8File(strFileName)
String containing the name of the file.
long _stdcall CNV_CheckUTF8Bytes(const char *szFileName);
Long: Returns zero if the file contains invalid UTF-8,
or a positive number if the file contains valid UTF-8,
where the value of the number indicates the nature of the encoded characters:
see CNV_CheckUTF8Bytes for more details.
If there is an error, like the file is missing or cannot be read,
then it returns a negative error code.
This is the same as CNV_CheckUTF8Bytes but for a file instead of a byte array.
For more details, see CNV_CheckUTF8Bytes.
This example examines two XML files containing Spanish characters like é and ó. The first is encoded in UTF-8; the second in Latin-1 (ISO-8859-1).
Dim strFileName As String Dim nRet As Long strFileName = "test-utf8.xml" nRet = CNV_CheckUTF8File(strFileName) Debug.Print "CNV_CheckUTF8File(" & strFileName & ") returns " & nRet strFileName = "test-iso88591.xml" nRet = CNV_CheckUTF8File(strFileName) Debug.Print "CNV_CheckUTF8File(" & strFileName & ") returns " & nRet
CNV_CheckUTF8File(test-utf8.xml) returns 2 CNV_CheckUTF8File(test-iso88591.xml) returns 0