CryptoSys PKI Toolkit Manual

CNV_CheckUTF8Bytes

Checks if a byte array contains valid UTF-8 characters.

VB6/VBA Syntax

Public Declare Function CNV_CheckUTF8Bytes Lib "diCrPKI.dll" (ByRef abInput As Byte, ByVal nBytes As Long) As Long

nLen = CNV_CheckUTF8Bytes(abInput(0), nBytes)

Parameters

abInput
[in] Byte array to be checked.
nBytes
[in] Long number of bytes in input array.

C/C++ Syntax

long _stdcall CNV_CheckUTF8Bytes(const unsigned char *lpInput, long nBytes);

Returns (VB6/C)

Long: Returns zero if the byte array contains invalid UTF-8, or a positive number if the byte array contains valid UTF-8, where the value of the number indicates the nature of the encoded characters:

ReturnsValueResult
PKI_CHRS_NOT_UTF80Not valid UTF-8
PKI_CHRS_ALL_ASCII1Valid UTF-8, all chars are 7-bit ASCII
PKI_CHRS_ANSI82Valid UTF-8, contains at least one multi-byte character equivalent to 8-bit ANSI
PKI_CHRS_MULTIBYTE3Valid UTF-8, contains at least one multi-byte character that cannot be represented in a single-byte character set.

.NET Equivalent

Cnv.CheckUTF8 Method (Byte[])

Remarks

Overlong UTF-8 sequences and illegal surrogates are rejected as invalid. Strings that return PKI_CHRS_ANSI8 (2) can be converted to Latin-1 format using the CNV_Latin1FromUTF8 function. Strings that return PKI_CHRS_MULTIBYTE (3) cannot be converted to Latin-1, and strings that return PKI_CHRS_ALL_ASCII (1) are already OK because they only consist of 7-bit ASCII characters.

Example

See the example in CNV_UTF8BytesFromLatin1.

See Also

CNV_CheckUTF8File CNV_Latin1FromUTF8Bytes CNV_UTF8BytesFromLatin1 CNV_ByteEncoding

[Contents] [Index]

[HOME]   [NEXT: CNV_CheckUTF8File...]

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