zsh-users
 help / color / mirror / code / Atom feed
From: Jan Fedak <J.Fedak@sh.cvut.cz>
To: zsh-users@sunsite.auc.dk
Subject: zsh changing cp1250 letters beyond recognition
Date: Wed, 7 Jun 2000 23:16:10 +0200	[thread overview]
Message-ID: <20000607231610.A6504@tornado.sh.cvut.cz> (raw)

[-- 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 - Maškarní plesy.mp3 04 - Maskarni plesy.mp3
mv 05 - Setkání s Puškinem.mp3 05 - Setkani s Puskinem.mp3
mv 06 - Svlíkni si košilku.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 - Vlaštovky.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 --]

                 reply	other threads:[~2000-06-07 21:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000607231610.A6504@tornado.sh.cvut.cz \
    --to=j.fedak@sh.cvut.cz \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).