Amin
Amin

Reputation: 87

How to convert unicode to ASCII?

I must remove Unicode characters from many files (many cpp files!) and I'm looking for script or something to remove these unicode. the files are in many folders!

Upvotes: 0

Views: 7816

Answers (2)

Bruce Newby
Bruce Newby

Reputation: 1

Open the srt file in Gaupol, click on file, click on save as, drop menu for character encoding, select UTF-8, save the file.

Upvotes: 0

unwind
unwind

Reputation: 399803

If you have it, you should be able to use iconv (the command-line tool, not the C function). Something like this:

$ for a in $(find . -name '*.cpp') ; do iconv -f utf-8 -t ascii -c "$a" > "$a.ascii" ; done

The -c option to iconv causes it to drop characters it can't convert. Then you'd verify the result, and go over them again, renaming the ".ascii" files to the plain filenames, overwriting the Unicode input files:

$ for a in $(find . -name '*.ascii') ; do mv $a $(basename $a .ascii) ; done

Note that both of these commands are untested; verify by adding echo after the do in each to make sure they seem sane.

Upvotes: 4

Related Questions