LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabWindows 2017 cannot open a file other editors can ("Cannot open binary files as text files")

When updating my FTDI DLL today (LibFT4222-v1.4.5.zip), I immediately ran in to a snag where LabWindows would not open the ftd2xx.h header file. I was able to open it in Notepad++ and Visual Studio Code and it looked fine, but LabWindows reported it as a binary file. I tried "save as" to a .txt, then renamed (same error). I tried copy/pasting from one editor to another (same error).

 

I wrote FTDI support and they said it was just a text file, and they did not support LabWindows and could not help.

 

I wrote a quick C program to parse the file byte-by-byte and print out offsets to any non-print character. It turns out, the file is full of zeros -- every other byte (some kind of unicode maybe?). While other editors (Code:Blocks IDE, VS Code, Notepad, etc.) open these, LabWindows cannot. The file will need to be converted to ASCII to work in the editor.

 

Compiling with the file will spit out various errors (" "ftd2xx.h"(5,1) error: source file is not valid UTF-8") and such. (GCC also cannot compile it.)

 

Hope this helps others who run in to it.

 

Just an FYI in case anyone else runs in to this.

Message 1 of 5
(854 Views)

Hello Allen,

your file is most likely in UTF16. You can convert it with the following linux command:

iconv -f UTF-16 -t ASCII//TRANSLIT ftd2xx.h >ftd2xx_ascii.h
0 Kudos
Message 2 of 5
(818 Views)

That's a useful utility to know -- I was unaware of it. FTDI support had me use the same file (but in the correct format) that came from their runtime installer (Windows drivers), but I wanted to leave this note in case someone else runs into it. Their support initially basically told me the file was not binary and it was fine, even though it wasn't 😉 

0 Kudos
Message 3 of 5
(792 Views)

Since you used Notepad++, you could have converted it there too, and maybe did unknowingly to UTF-16 when opening it in Notepad or Notepad++,

Notepad++ has a menu where it shows what format the current file is. You can select a different one and then save it and it converts the file to that format.

 

You either want ANSI/ASCII or UTF-8 without BOM for maximum compatibility..

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 5
(785 Views)

Good to know. Initially, I thought there were just bad characters in the file so I did a copy and paste in to a "dumb" editor. Turns out, those dumb editors supported non-ASCII 😉 and just copied all the bytes.

0 Kudos
Message 5 of 5
(782 Views)