At 7:54 PM +0200 9/30/2002, Adriano Allora wrote: >On the one hand I didn't express myself very well, but for the other hand I found >other aspects of the problem. > >Actual situation: I work with mac osx.2, vi editor, a pack of dos files to work on. >When I open my files with vi I see some strings instead of stressed letters and signs. >For instance: >carriage return = ^M >u grave = \xf9 >[...] >so, I don't know I can face the problem: to create an array of strings to substitute >is a non-sense, because of I haven't got two lists in one-to-one correspondence... >er, I suppose (I'm not sure). >What's yous opinion about?
I had the suspicion at the onset that this was a more involved issue than the line feed... % perl -pi -e "s/(\015\012|\012|\015)/\n/g" ....problem. The files were created using a character set that is different from the character set that vi is using. (My guess is that Terminal's using Mac-Roman, but other likely suspects are UTF-8 or ISO 8859-1.) You should be able to translate between the character sets fairly easily using Encode::Byte, but you'll need 5.7.3 or later - it's now part of the 5.8.0 core. You could probably borrow from the source to create a version that doesn't need the UTF-8 flag. There's also Unicode::Map8, which looks like it can similarly be leveraged to meet your needs. And of course, it's a moderately simple exercise to prepare a couple of hashes to map forward and backward between two character sets. -Charles Euonymic Solutions [EMAIL PROTECTED]
