• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

ascii to unicode text file conversion

Hi, I am looking for a utility to convert text files from ascii to unicode. I have tried the native2ascii (-reverse) util that comes with JDK but it doesn't cut it. I want to process directories of files at a time, that util does 1 at a time. I wrote a small program to run this util for every file in a dir but it runs way too slow and it then screws up my files.

If there isn't a decent util like that around, i'll pay many more points for a nice perl
script or C file (if you write it in C-> i'm using linux kernel 2.0.35 in slackware with libc5). I could do this in Java but won't bother if someone gives me a perl or C file.

Thanks in advance
-Rasp (rshortt@quantumtraining.nb.ca)
0
rasp
Asked:
rasp
1 Solution
 
ijdugganCommented:
You can try using the find program. Go to the base of the file tree and type this to make native versions of the files with extension .ntv. This is c shell code and assumes the files all have extension .asc.

for file (`find . -name '*.asc' -print`)
native2ascii -reverse $file `echo $file | sed 's/.asc/.ntv/'`
end

Or in perl:

#!/usr/athena/bin/perl

@files = split(/\n/, `find . -name '*.sh'`);

for (@files) {
    $outfile = $_;
    $outfile =~ s/(.*)\.asc$/$1\.ntv/;
    system("native2ascii -reverse $_ $outfile");
}


0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now