Subject: German Umlauts - next questions

From: Harald Wagener <[email-masked]>
Date: Thu, 02 Aug 2001 10:31:24 +0200

Is there a script that converts filenames in MacRoman encoding to latin1 encoding.
I looked at google, but it did not give me anything.

Regards,
	Harald

-- 
Harald Wagener      |                                Systemadministrator 
FCB/Wilkens GmbH    |                              Tel.:+49-40-2881-1252 
An der Alster 42    |                              Fax.:+49-40-2881-1263 
20099 Hamburg       |                         http://www.fcb-wilkens.com

---

From: Thomas Kaiser <[email-masked]>
Date: Thu, 02 Aug 2001 10:49:54 +0200

> I looked at google, but it did not give me anything.

you might want to use GNU recode (UNIX) or Tanakas OSAX 2.0 (MacOS -->
<http://osaxen.com>) to convert between.

recode: LATIN1FILENAME=`echo $MACROMANFILENAME | recode applemac..latin1`

Tanakas OSAX: set LATIN1FILENAME to (MT Convert W code MACROMANFILENAME from
MacRoman to Latin1)

Regards,

Thomas

---

From: Axel Rose <[email-masked]>
Date: Thu, 2 Aug 2001 12:47:44 +0200

Hello Harald,

with Perl you can help yourself.

First a little help script to find the encodings:

#!/usr/bin/perl

printf( "ä = %x\n", ord('ä') );
printf( "ö = %x\n", ord('ö') );
printf( "ü = %x\n", ord('ü') );
printf( "Ä = %x\n", ord('Ä') );
printf( "Ö = %x\n", ord('Ö') );
printf( "Ü = %x\n", ord('Ü') );
printf( "ß = %x\n", ord('ß') );

__END__

run on Mac results:

ä = 8a
ö = 9a
ü = 9f
Ä = 80
Ö = 85
Ü = 86
ß = a7

run under Unix results:

ä = e4
ö = f6
ü = fc
Ä = c4
Ö = d6
Ü = dc
ß = df

Then use this to build your own converter:

#!/usr/bin/perl -w
use strict;

my $filename = "achja-äöü-ÄÖÜ-ß-/-entreé";
print isoencode( $filename ), "\n";

sub isoencode
{
        my $input_name = $_[0];

        # unvollstaendig!! TODO
        # aus ISO-8859-1 nach ES Kodierung

        # /, ae, oe, ue, Ae, Oe, Ue, sz
        $input_name =~ s/\//:2f/g;

        $input_name =~ s/\xe4/:8a/g;
        $input_name =~ s/\xf6/:9a/g;
        $input_name =~ s/\xfc/:9f/g;
        $input_name =~ s/\xc4/:80/g;
        $input_name =~ s/\xd6/:85/g;
        $input_name =~ s/\xdc/:86/g;
        $input_name =~ s/\xdf/:a7/g;

        # DEL Char 0x7f, 127
        $input_name =~ s/\x7f/:7f/g;

        return( $input_name );
}

__END__

With input in MacRoman it is easier because you don't need
a translation table. Just translate \x8a to ":8a".

#!/usr/bin/perl -w
use strict;

my $s = "abc-äöü-def";
# beware the "/" in Mac filenames
$s =~ s/\//:2f/g;
$s =~ s/[\x7f-\xff]/&enc($&)/ge;
print $s, "\n";

sub enc
{
	my $arg = shift;
	return sprintf( ":%x", ord( $arg ) );
}

__END__

This of course is incomplete and only provided as a basis for
your own customization.

HTH

Axel
----------------------------------------------------------------------
Axel Rose, Springer & Jacoby Digital GmbH & Co. KG, mailto:[email-masked]
pub PGP key 1024/A21CB825 E0E4 BC69 E001 96E9  2EFD 86CA 9CA1 AAC5
            "Was man nicht weiß, das eben braucht man.
             Und was man weiß, kann man nicht brauchen."

---

From: Harald Wagener <[email-masked]>
Date: Wed, 08 Aug 2001 13:32:51 +0200

Hello all,

thanks to generous and detailed input by folks on-list and off-list,
we have been able to generate a script that recodes file names in 
AppleDouble encoding to file names in latin1-encoding. 
Special thanks go to Thomas Kaiser, who has helped us a lot.

Attached You will find the script latinize.pl, which will do a basic
conversion, without any checks for overwriting existing files that 
bear the new name of the file converted. It went through our 60 Gig 
archive in less than 10 minutes. 17.000 files and folders were renamed.

Ah, yes, consider it GPLed, and use on Your own risk. Testing shows that 
clients don't do too well if the encoding of an appletalk volume is 
changed without restarting the netatalk service.

Regards,
	Harald