LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

INI file with Multibyte characters for languages question

Solved!
Go to solution

Hello,

 

I am doing research on multiple language support in our CVI programs.
I am new to multibyte programming, as I have always coded in English until now.

 

I have found the Interface Localizer and have toyed around with translating my GUI controls. That works ok, except on the title bar which displays in some code other than the language I am translating. But this will not work for popup messages or dynamic displays.

I have read a few of the white papers. I am not too worried about Run Time messages, mostly I am worried about program specific prompting and the GUI.

 

I have seen many topics suggesting using an external INI file to translate specific messages in my program. So I have tried creating an ini file that uses Unicode and a chinese character.
When I call Ini_NumberOfSections using this INI file, my software returns a count of 0 sections when there is, in fact, 1 section. This occurs if I format my INI file in any format other than ANSI, such as Unicode.

 

So my question is simple: How do I read an INI file, and specifically the tag, using multibyte characters in Unicode?

Is it a setting? Or do I need to write my own INI read and parsing function?

 

Thank you very much.

Veni Vidi Duci
0 Kudos
Message 1 of 6
(5,296 Views)

Hi DB_IQ,

 

I have been searching a bit regarding your questions and I was able to find some information that I thought might be useful for you (in case you have not seen it already) the first one is the following Community post that actually talks about an alternate method on how could you manage ini files from  LabWindows/CVI. Also I found out the Knowledge Base article Using LabWindows™/CVI Localization Utility with Single/Multiple Byte Languages which talks about the method to use the Localization Utility and translate the menu into a single byte font language.

 

I hope that you can find this information helpful!

Regards,

Sil.VI
0 Kudos
Message 2 of 6
(5,249 Views)

I tried the alternative front panel method. Unfortunately, it also does not accept Unicode characters.

The INI file must be formated in ANSI, which means I cannot create an INI file that includes Chinese, Japanese, or other Unicode characters.

 

So, again, do I need to write my own file reading and parsing function to read Unicode files?

 

I was already aware of the Localizer tool. That works fine for the GUI.

It is my understanding that the operating system of the computer has to be in the correct language to properly display the title bar and the prompt messages, otherwise you get a sort of western version of the language. See the attached screenshot for an example. What I am doing is reading the character string from the left control and printing the same string using the a popup, like so:

char test[100] = {0};

GetCtrlVal(pnl.top, PANEL_STRING, &test[0]);

MessagePopup ("Test", test);

 

Untitled.png

 

Veni Vidi Duci
0 Kudos
Message 3 of 6
(5,218 Views)

Just an aside: there are many different open-source INI libraries in C. You may want to see if some of them fare better with multichar than the NI one.

0 Kudos
Message 4 of 6
(5,176 Views)

Thanks for the replies.

 

I performed a test with a .csv file, using english and chinese characters.

I was able to correctly read the .csv file and display the Chinese characters.

 

Also, I installed my test program, above, on a seperate PC. I setup that PC to display in Chinese. The message popup appeared to work correctly on that machine, which matches what I read elsewhere it should do. Apparently the popups use something in Windows to display correctly.

 

I have some more leg work to do before I call this issue "closed". So for now, I will leave it open. But I will definately post my results.

Veni Vidi Duci
0 Kudos
Message 5 of 6
(5,168 Views)
Solution
Accepted by topic author DB_IQ

OK,

 

I have completed my first leg of R&D. Here is what I know:

 

I tried several formatting options, including XML, TXT, CSV and XLSX (Excel).

 

Using the CVIXML is not an option (at least the way I tested it) since it also does not accept Unicode in CVI. I did a little research and found how to configure my XML file in unicode, but whenever I try to read it using CVIXML, the result is a failure. So I gave up on that method.

 

A .csv file is not a good option because of the way the file behaves in Excel. With Unicode caracters, the file does not open as expected and all my data is in the first column. If you strictly use a text editor like notepad, you can read the .csv file and use it in CVI. The only issue is you need to compensate for the multibyte characters, which I did not do. So, due to the undesireable editing of the .csv, I eliminated this as an option.

 

So here is the solution I came up with. I am using the Excel Report commands (via excelreport.fp in toolslib).

Using this method I can format my language options in Excel, display my Unicode characters, and still open the file as expected in CVI.  I simply open my Excel file and load all the language options into memory, then close the Excel file.

The only caviats are speed and the Unicode does not display properly if your operating system is configured to a non-unicode format. But this is not an issue, as that is a windows setting. In my typical US setting, the unicode characters will appear as ?? but if I change my localized language to, for example, Chinese then the unicode will appear normally.

 

So, for now, this is the solution I have identified. Thank you for the advice. Hopefully others will find this useful.

Veni Vidi Duci
0 Kudos
Message 6 of 6
(5,081 Views)