А вы сравниваете строку с целым числом? попробуйте if (num[0]=="1")
iconv
может сделать это:
Usage: iconv [OPTION...] [FILE...]
Convert encoding of given files from one encoding to another.
Input/Output format specification:
-f, --from-code=NAME encoding of original text
-t, --to-code=NAME encoding for output
Information:
-l, --list list all known coded character sets
Output control:
-c omit invalid characters from output
-o, --output=FILE output file
-s, --silent suppress warnings
--verbose print progress information
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
Ни ANSI, ни Unicode не являются кодировкой. Необходимо будет знать кодовую страницу ANSI входного файла и кодирования Unicode (UTF8 или UTF16 - LE или БЫТЬ), прежде чем можно будет использовать один из предложенных инструментов (таких как iconv)
Можно также легко преобразовать кодировку в Python:
inf = open("infile.txt")
data = inf.read().decode("latin1")
inf.close()
outf = open("outfile.txt", "w")
outf.write(data.encode("utf-8"))
outf.close()
Вот решение Powershell
$lines = gc "pathToFile"
$lines | out-file -enconding Unicode