Code Generation for Characters and Strings

The code generation software translates the 16-bit Unicode® encoding of a character in MATLAB® to an 8-bit encoding that the locale setting determines. The code generation software does not support characters that require more than 1 byte in MATLAB. This restriction applies to constant strings and strings that are passed between MATLAB and the code generation software. For example, the restriction applies to entry-point function inputs and to outputs from extrinsic calls. For code generation, some MATLAB functions accept only 7-bit ASCII strings. See Functions and Objects Supported for C and C++ Code Generation — Alphabetical List.

If a character is not in the 7-bit ASCII codeset, casting the character to a numeric type, such as double, produces a different result in the generated code than in MATLAB. A best practice for code generation is to avoid performing arithmetic with characters.

More About

Was this topic helpful?