CryptoSys PKI Toolkit Manual

CNV_Latin1FromUTF8Bytes

Converts UTF-8 encoded array of bytes into a Latin-1 string, if possible.

VB6/VBA Syntax

Public Declare Function CNV_Latin1FromUTF8Bytes Lib "diCrPKI.dll" (ByVal strOutput As String, ByVal nOutChars As Long, ByRef abInput As Byte, ByVal nBytes As Long) As Long

nLen = CNV_Latin1FromUTF8Bytes(strOutput, nOutChars, abInput(0), nBytes)

Parameters

strOutput
[out] String to receive the output.
nOutChars
[in] Long specifying the maximum number of characters to be received.
abInput
[in] Byte array containing UTF-8 encoded data.
nBytes
[in] Long number of bytes in input array.

C/C++ Syntax

long _stdcall CNV_Latin1FromUTF8Bytes(char *szOutput, long nOutChars, const char *lpInput, long nBytes);

Returns (VB6/C)

Long: If successful, the return value is a positive number indicating the number of characters (bytes) in the output string, or number of characters required if nOutChars is set to zero; otherwise it returns a negative error code.

.NET Equivalent

Use System.Text.Encoding.UTF8.GetString(bytes).

Remarks

Will set up to nOutChars characters in the output string. If nOutChars is zero, it returns the required number of characters. The input must be valid UTF-8 data. Possible errors are INVALID_DATA_ERROR indicating invalid UTF-8 input and OUT_OF_RANGE_ERROR which indicates that the output would contain a character greater than 8 bits in size.

Example

See CNV_UTF8BytesFromLatin1.

See Also

CNV_UTF8BytesFromLatin1 CNV_CheckUTF8Bytes CNV_ByteEncoding

[Contents] [Index]

[HOME]   [NEXT: CNV_UTF8FromLatin1...]

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