Kabar Shfq
Kabar Shfq

Reputation: 1

batch file: Save exported text file as encoding utf-8

I created a batch file to export some data from a software that I use. It exports the data and it saves the data in text format. exactly what I need it to do but the problem is that the encoding for the export text file is saved as ANSI. I need it to be saved a utf-8_bin. The reason for this is because I need it be imported into MySQL. The schema for MySQL is utf-8_bin.

Here is the batch file:

START /WAIT ksexport.exe /NOP /NODISPLAY Type=SA File=xprt\Sle\SInv.txt File2=xprt\Sle\SInvDtl.txt Tab=on Start=01/01/01 End=01/30/17

Upvotes: 0

Views: 3617

Answers (2)

Maybe you can try in your batch script something like:

@ECHO OFF
:: Make sure that your batch file is in "UTF-8 without BOM" encoding
:: Notepad++ have the ability to change the file encoding

:: Then, change the codepage in your script:
CHCP 65001

:: And now, you can export your data without problems
START /WAIT ksexport.exe /NOP /NODISPLAY Type=SA File=xprt\Sle\SInv.txt File2=xprt\Sle\SInvDtl.txt Tab=on Start=01/01/01 End=01/30/17

::EOF

Upvotes: 1

Simon Catlin
Simon Catlin

Reputation: 2229

Try using CMD.EXE /U, i.e.:

start /wait %COMSPEC% /U /C ksexport.exe ........

The /U makes CMD.EXE output Unicode text. I'm not sure if this will affect the output of KSEXPORT.EXE though.

Alternatively, use PowerShell ;-)

Upvotes: 0

Related Questions