Working with Project and File Encoding
LabWindows/CVI supports ANSI and UTF-8 string encoding. You can specify the string encoding of your new project, a new project created from a template, or migrate your ANSI project to UTF-8. The following sections describe additional considerations for encoding of individual files.
If you specify the encoding of your project as UTF-8, the CVI_UTF8 compiler define is added to the Predefined Macros. The CVI_UTF8 macro automatically resolves functions that take string parameters to the UTF-8 version of the function if the function has UTF-8 support. The UTF-8 version of the function is suffixed with Utf8 while the ANSI version is suffixed with Ansi. For example, SetCtrlAttribute resolves to SetCtrlAttributeUtf8.
![]() |
Note Refer to Programming for UTF-8 Encoding for more information about working with UTF-8 encoding and Programming for Multibyte Character Sets for information about working with ANSI multibyte character sets. |
Adding Files to an Existing Project
LabWindows/CVI automatically detects the encoding of each file you add to your project. If the file does not contain any extended characters, LabWindows/CVI encodes the file in the same encoding as the project.
If you add a file with a different encoding than the project encoding, LabWindows/CVI displays a message warning you about potential information loss, unexpected application behavior, and build warnings. To disable this message, go to Options»Environment and uncheck the Warn when file encoding doesn’t match the project encoding check box.
Opening, Reopening, and Converting File Encoding
LabWindows/CVI automatically detects the encoding of each file you open. If a character cannot be represented by the automatically detected encoding, it is replaced by ? and the file becomes read-only. LabWindows/CVI displays the encoding of the open file in the status bar.
If the file encoding is ANSI, LabWindows/CVI interprets the characters using the Character set for interpreting ANSI strings setting you specify in Options»Environment. To reopen the file using a different encoding, go to Edit»File Encoding»Reopen File As and select either UTF-8 or a different ANSI character set.
![]() |
Note Reopening a file with a different encoding changes the interpretation of the characters but does not alter the file contents. Reopening a file requires a reload from disk. If you have any unsaved changes when you reopen the file, you will receive a message asking you to save the file. Saving the file can lead to data loss. |
You can convert a file to a different encoding. Converting a file changes the contents so the same characters are represented in the new encoding. To convert a file, go to Edit»File Encoding»Convert File To and select the new encoding. LabWindows/CVI interprets the ANSI characters using the Character set for interpreting ANSI strings setting you specify in Options»Environment.
![]() |
Note Conversions from UTF-8 to ANSI might result in data loss. LabWindows/CVI replaces characters that cannot be represented in the ANSI character set you are converting with ?. |