Page 1 of 1

utf-16 to utf-8

Posted: Thu Oct 03, 2013 4:05 pm
by pp
How to convert a textfile from utf-16 to utf-8 inside switch with the execute command.

In the terminal it's working:

iconv -f utf-16 -t utf-8 input_utf16.txt > output_utf8.txt



How to set the paths in switch, see screenshot...



(and maybe some tips on setting the 'output' and 'fail if exit code is')










utf-16 to utf-8

Posted: Fri Oct 04, 2013 1:26 pm
by freddyp
"%1"/_[Job.etc. is wrong. %1 is a complete path to the input file, so "%1" is all you need.



As the command generates output, having "Output" set to "None" is also not going to work. I recommend choosing "Updated input job" and in the "Arguments" you then simply have:

-f utf-16 -t utf-8 "%1"



If you want to rename the file, do that with a separate "Rename job" afterwards.



Freddy

utf-16 to utf-8

Posted: Fri Oct 04, 2013 2:40 pm
by pp
The problem is iconv first creates the output file and can't write over the input file. So i have to use a > and i think a %2 or %3 for the output-path (and filename?) to write to.

And i don't get Hard-coded paths to work...

utf-16 to utf-8

Posted: Fri Oct 04, 2013 3:07 pm
by freddyp
In that case add > "%2" and choose "File at path" as "Output"

utf-16 to utf-8

Posted: Fri Oct 04, 2013 3:20 pm
by pp
In that case the file is disappearing...

(with copy input path: no)

when fail exit code set to Nonzero it goes into the Problem jobs



Error message:

04.10.2013 15:10:59.853 error Execute command

Operation: Job failed because outcode is nonzero, outcode = [%1]

Argument: 1

Flow: utf16 naar utf8

Element: iconv

Ticket: 00K62

File: _00K62_16.txt

utf-16 to utf-8

Posted: Fri Oct 04, 2013 4:09 pm
by pp
In the log: File '_00K68_16.txt' was sent to null; it will be deleted when the entry point finishes



and not the first in the forum: execute command to launch python



I think it's the same problem... "%1" > "%2"



it's in the > character

utf-16 to utf-8

Posted: Fri Oct 04, 2013 4:32 pm
by dkelly
You will need to wrap the command in a shell or batch script.



iconv returns 0 if successful and 1 if not.

Re: utf-16 to utf-8

Posted: Wed May 15, 2024 3:45 pm
by May
I know this is an unbelievably old topic, but I actually needed it right now

Code: Select all

#!/bin/sh
#
sourceFilePath="$1"
targetFilePath="$2"
iconv -f MacRoman -t UTF-8 $sourceFilePath > $targetFilePath
to convert from MacRoman to UTF-8

"File at path" as "Output" is correct, but the command itself wouldnt work solely in switch, cause the > operator is "mishandled" by switch
thus you rly need to wrap it in a mini shell script