Main Content

matlab::engine::convertUTF16StringToUTF8String

Convert UTF-16 string to UTF-8 string

Description

std::string convertUTF16StringToUTF8String(const std::basic_string<char16_t>& utf16string)

Convert a UTF-16 string to a UTF-8 string.

Include

Namespace:

matlab::engine
IncludeMatlabEngine.hpp

Parameters

const std::basic_string<char16_t>& utf16string

A UTF-16 string

Return Value

std::string

A UTF-8 string

Exceptions

matlab::engine::OutofMemoryException

The function failed to allocate memory.

matlab::engine::TypeConversionException

The input type cannot be converted to std::string.

Examples

Convert String

Convert a matlab::engine::String (UTF-16 string) to a std::string (UTF-8 string).

matlab::engine::String matlabStatement = (u"sqrt(12.7);");
std::string cmdString = convertUTF16StringToUTF8String(matlabStatement);

Version History

Introduced in R2017b