* zsh changing cp1250 letters beyond recognition
@ 2000-06-07 21:16 Jan Fedak
0 siblings, 0 replies; only message in thread
From: Jan Fedak @ 2000-06-07 21:16 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 2400 bytes --]
Hi.
I have written simple script (attached) that gets filenames (in $*).
The filenames possibly contain letters in cp1250 (windows encoding for
middle and eastern Europe) or iso-8859-2.
It should change the letters with accents to plain ascii and if
there's a difference between the original and new name, it renames the
file.
Now, if I use bash to run the script, everything works just fine. But
when I replace #!/bin/bash with #!/bin/zsh, all those strange cp1250
characters (\232\235\236\212\215\216) get replaced with other (and
equally strange) ones. Renaming and tr don't work correctly then.
As an example, I attach a small file you can try to run (to see the
behavior) -- runme.sh and outputs:
with bash:
mv 03 - Tři sudičky.mp3 03 - Tri sudicky.mp3
mv 04 - Makarní plesy.mp3 04 - Maskarni plesy.mp3
mv 05 - Setkání s Pukinem.mp3 05 - Setkani s Puskinem.mp3
mv 06 - Svlíkni si koilku.mp3 06 - Svlikni si kosilku.mp3
mv 07 - Píseň psaná na vodu.mp3 07 - Pisen psana na vodu.mp3
mv 08 - Kdy mě brali za vojáka.mp3 08 - Kdyz me brali za vojaka.mp3
mv 10 - Děvenka těstí a mládenec al.mp3 10 - Devenka Stesti a mladenec Zal.mp3
mv 11 - Básníci chlípníci.mp3 11 - Basnici chlipnici.mp3
mv 12 - Zestárli jsme lásko.mp3 12 - Zestarli jsme lasko.mp3
mv 13 - Třiatřicet.mp3 13 - Triatricet.mp3
mv 14 - Vlatovky.mp3 14 - Vlastovky.mp3
mv 15 - Píseň pro Lenku.mp3 15 - Pisen pro Lenku.mp3
mv 19 - Přelezl jsem plot.mp3 19 - Prelezl jsem plot.mp3
and with zsh (differences in 04, 05, 06, 10...):
mv 03 - Tři sudičky.mp3 03 - Tri sudicky.mp3
mv 04 - Makarní plesy.mp3 04 - Makarni plesy.mp3
mv 05 - Setkání s Pukinem.mp3 05 - Setkani s Pukinem.mp3
mv 06 - Svlíkni si koilku.mp3 06 - Svlikni si koilku.mp3
mv 07 - Píseň psaná na vodu.mp3 07 - Pisen psana na vodu.mp3
mv 08 - Kdy mě brali za vojáka.mp3 08 - Kdyz me brali za vojaka.mp3
mv 10 - Děvenka $těstí a mládenec }al.mp3 10 - Devenka $testi a mladenec }al.mp3
mv 11 - Básníci chlípníci.mp3 11 - Basnici chlipnici.mp3
mv 12 - Zestárli jsme lásko.mp3 12 - Zestarli jsme lasko.mp3
mv 13 - Třiatřicet.mp3 13 - Triatricet.mp3
mv 15 - Píseň pro Lenku.mp3 15 - Pisen pro Lenku.mp3
mv 19 - Přelezl jsem plot.mp3 19 - Prelezl jsem plot.mp3
Jan
--
Jan Fedak talk:jack@tornado.sh.cvut.cz
mailto:J.Fedak@sh.cvut.cz mailto:jack@mobil.cz
Linux - the ultimate NT Service Pack.
[-- Attachment #2: removecz --]
[-- Type: text/plain, Size: 472 bytes --]
#!/bin/bash
# ^ must have bash here. possibly a bug in zsh renders this script useless
trfrom='áčďěéíňóř\232\235ůúý\236ÁČĎÉĚÍŇÓŘ\212\215ŮÚÝ\216'
trto='acdeeinorstuuyzACDEEINORSTUUYZ'
if [ "x$1" = x-iso ]; then
trfrom='áčďěéíňóřšťůúýžÁČĎÉĚÍŇÓŘŠŤŮÚÝŽ'
shift
fi
while [ $# -gt 0 ]; do
name="$1"
shift
nonczname=`echo "$name" | tr $trfrom $trto`
if [ "$name" != "$nonczname" ]; then
echo mv "$name" "$nonczname"
mv "$name" "$nonczname"
fi
done
[-- Attachment #3: runme.sh --]
[-- Type: application/x-sh, Size: 684 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-06-07 21:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-07 21:16 zsh changing cp1250 letters beyond recognition Jan Fedak
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).