CryptoSys PKI Toolkit Manual

CNV_CheckUTF8File

Checks if a file contains valid UTF-8 characters.

VB6/VBA Syntax

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

nLen = CNV_CheckUTF8File(strFileName)

Parameters

strFileName
[in] String containing the name of the file.

C/C++ Syntax

long _stdcall CNV_CheckUTF8Bytes(const char *szFileName);

Returns (VB6/C)

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.

.NET Equivalent

Cnv.CheckUTF8File Method

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]

[HOME]   [NEXT: CNV_HexFilter...]

Copyright © 2004-12 D.I. Management Services Pty Ltd. All rights reserved.