LabWindows/CVI

Content Type
Programming Language
Current manual

MBStrToUTF8StrBuf

MBStrToUTF8StrBuf

int MBStrToUTF8StrBuf (const char multibyteString[], char UTF8String[], size_t bufferSizeInBytes, int flags);

Purpose

Converts an ANSI encoded multibyte string to a UTF-8 encoded string using the native character set and stores the converted string in the buffer.

The native character set corresponds to the selected language in the Control Panel for non-Unicode programs.

Parameters

Input
Name Type Description
multibyteString const char [] The ANSI multibyte Null-terminated string you want to convert.
bufferSizeInBytes size_t Number of bytes in the utf8Str parameter.
flags int Flags indicating the conversion type.

Setting flags to kErrInvalidChars makes the function fail if an invalid input character is encountered.
Output
Name Type Description
UTF8String char [] Buffer to receive the null-terminated string encoded in UTF-8.

Return Value

Name Type Description
status int Result of the conversion.

Code Description
0 Success.
-4 Insufficient memory to complete operation.
-5 Invalid parameter.
-10 Buffer size too small.
-11 Some characters could not be converted.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 2020 and later

Example

Refer to utility\StringConversions\StringConversions.cws for an example of using the MBStrToUTF8StrBuf function.

Was this information helpful?