0

I'm having a little problem automating a test with UFT (vbscript). I need to open a csv file, modify it, and then save it again. The problem is that when I open the file in Notepad++, it shows the encoding as "UCS-2 LE BOM". This file is then injected into our system for processing and if I change the encoding to ANSI, the injection will fail because the file seems to lose its column structure, and I'm not sure it is readable for the system anymore.

From what I understand, it's not possible to do it directly with vbscript but any idea how I could do it with powershell for example? Is there a notepad++ command line to change the encoding of a file for example?

Thanks

Mu21
  • 17
  • 10
  • Not sure I understand your question. In any case (not-really-)"ANSI" and UCS-2 are very different encoding: one with always one byte per char, and the other with two bytes per char. You cannot expect to get sensible output if you tell the computer to read completely wrong. Trick: search for UTF-16 BOM. the conversion from/to (really-it-is-not-done-by-)"ANSI" is the same. – Giacomo Catenazzi Feb 21 '20 at 10:23
  • And I'm not sure I understand your answer :-). The question is simple: If I open the file in VBScript, I will get some jibberish and I cannot modify it. So what can I do to solve this problem knowing that I need to open the file, read it, modify some values and save it. The saved file needs to be encoded in "UCS-2 LE BOM" – Mu21 Feb 24 '20 at 10:11
  • https://stackoverflow.com/questions/36152339/append-vbcrlf-to-ucs-2-little-endian/36152812#36152812 with https://learn.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/314cz14s(v=vs.84)?redirectedfrom=MSDN, so using `format = -1`? [https://stackoverflow.com/questions/52339439/how-to-create-utf-16-file-in-vbscript for creating files] – Giacomo Catenazzi Feb 24 '20 at 10:49
  • Thanks for the suggestion but it doesn't work. format = -1 reads jibberish so I cannot modify anything or even save the file and the other 2 formats give me an error. – Mu21 Feb 24 '20 at 13:04

0 Answers0