帮助中心帮助中心
指定要在从 Simulink 模型生成的代码中使用的编码
slCharacterEncoding(encoding)
encoding = slCharacterEncoding()
示例
slCharacterEncoding(encoding) 指定在从 Simulink® 模型生成的代码中使用的字符集。字符集编码会影响生成代码中的注释。
encoding
encoding = slCharacterEncoding() 返回当前 Simulink 字符集编码。
全部折叠
假设您为嵌入式目标生成代码,并且您使用的编译器要求源代码仅包含 ASCII 字符。
ASCII
请使用以下命令:
slCharacterEncoding('US-ASCII')
假设您的模型包含非 ASCII 字符(多语言字符、特殊符号),并且您需要这些注释在您的生成代码中易于阅读。
如果您的编译器支持 UTF-8,请在 Windows® 上使用以下命令:
UTF-8
slCharacterEncoding('UTF-8')
UTF-8 是 Linux® 和 Mac 上的默认编码。
假设您的模型包含日语文本,但您的计算机配置为英语语言区域设置。您需要生成具有 'Shift_JIS' 编码文本的代码,以便使用 'Shift_JIS' 作为其区域特定设置编码的团队成员能够在生成代码中查看日语文本。
'Shift_JIS'
slCharacterEncoding('Shift_JIS')
'US-ASCII'
'UTF-8'
将字符编码设置为支持的编码值。
在 R2006a 之前推出
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office