CryptoSys PKI Pro Manual

CNV_CheckUTF8File

Checks if a file contains valid UTF-8 characters.

VBA/VB6 Syntax

Public Declare Function CNV_CheckUTF8File Lib "diCrPKI.dll" (ByVal strFileName As String) As Long

nLen = CNV_CheckUTF8File(strFileName)

C/C++ Syntax

long __stdcall CNV_CheckUTF8File(const char *szFileName);

Parameters

szFileName
[in] containing the name of the file.

Returns (VBA/C)

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.

.NET Equivalent

Cnv.CheckUTF8File Method

C++ (STL) Equivalent

static int dipki::Cnv::CheckUTF8File (const std::string &fileName)

Python Equivalent

static Cnv.utf8_check_file(filename)

Remarks

This is the same as CNV_CheckUTF8Bytes() but for a file instead of a byte array. For more details, see CNV_CheckUTF8Bytes().

Example

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

See Also

CNV_CheckUTF8Bytes

[Contents] [Index]

[PREV: CNV_CheckUTF8Bytes...]   [Contents]   [Index]   
   [NEXT: CNV_HexFilter...]

Copyright © 2004-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-09-23T07:52:09Z.