LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

File sometimes saves as unicode, sometimes as ANSI problem

Hi all,

 

I'm having an issue whereby a .vi I've created to save string data sometimes saves the .txt file as ANSI and sometimes as Unicode. Unfortunately the unicode appears to be Chinese characters when opened in notepad. When I open the same file in notepad++ the data is there but in unicode format. I'd like to try and understand why this is happening and fix it. Any advice would be appreciated. I've included the .vi, ansi output example and a unicode output example.

 

Brief description of the vi functionality:

 

The .vi simply saves the input string to the filename (and path) supplied in Log File Path. It checks conditions for file existing, path exisiting and creates any missing pieces (folders, files). Then it opens the file for writing, sets 'append' and writes to the files. Lastly it closes the file.

 

I can not figure out what is causing it to sometimes save as unicode and sometimes as ansi. Please let me know if there is anything further I can provide.

 

Cheers,

Alex

 

Alexander H. | Software Developer | CLAD

Download All
0 Kudos
Message 1 of 4
(3,278 Views)
See attached code. I don't know if it will make a difference but I don't know why you had all the local variables. You can also move the file setting constants outside the case structures, i just didn't bother to.
Message Edited by for(imstuck) on 05-19-2010 09:00 PM
0 Kudos
Message 2 of 4
(3,257 Views)
You didn't attach the ANSI example text file. I don't see anything in that Log.vi that would affect the way it is being saved to the file.  I would suspect your issue is with whatever VI you have that calls this subVI.  That it is sending different string values.
0 Kudos
Message 3 of 4
(3,238 Views)

alexhunt wrote:

Hi all,

 

 

I can not figure out what is causing it to sometimes save as Unicode and sometimes as ANSI. Please let me know if there is anything further I can provide.

 

 


Hi, alex,

 

The file seems to be saved correctly and its not saved as Unicode. The file opened as Unicode.

 

Do simple experiment:

 

1. Start Notepad:

01.png

 

2. Type 'AAAA BBB CCC DDDDD':

02.png

 

3. Save it. As you can see in hex viewer, my file is correct:

03.png

 

4. Now open this file in notepad, you will be surprised:

04.png 

 

This is true for XP, not sure how it works with Windows 7.

 

Try to open your file in that way:

 

05.png

Andrey.

 

 

0 Kudos
Message 4 of 4
(3,217 Views)