#
# Konvertierung der Umlautdarstellung verschiedener Zeichensaetze
#
#############################################################################
#    Copyright (C) 1993
#    Andreas Koppenhoefer (koppenh@dia.informatik.uni-stuttgart.de)
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#############################################################################
# @(#)$Id: umlaut.pl,v 1.2 1993/06/15 15:34:01 koppenh Exp $
# $Log: umlaut.pl,v $
#    Revision 1.2  1993/06/15  15:34:01  koppenh
#    Neue Release Nummer;
#
#    Revision 1.1.0.1  1993/06/08  19:07:00  koppenh
#    Uebersicht Umlautdarstellungen zugefuegt;
#    Umlaute fuer NeXT-Systeme eingebaut: Dank an Detlef Droege
#    (droege@infko.uni-koblenz.de);
#
#############################################################################

# usage:
#	$text = &ibm2iso ($some_text);
#	$text = &next2iso ($some_text);
#	$text = &tex2iso ($some_text);
#	$text = &ascii2iso ($some_text);
#	$text = &iso2ibm ($some_text);
#	$text = &iso2next ($some_text);
#	$text = &iso2tex ($some_text);
#	$text = &iso2ascii ($some_text);
#	$text = &iso2umlaut( $some_text);

#
# Uebersicht Umlautdarstellungen
#
#	7bit	tex	8bit (ibm)	iso8859		NeXT
#	ascii		     octal	     octal	     octal
#	ae  {	"a	M-^D  204	M-d   344	M-Y   331
#	oe  |	"o	M-^T  224	M-v   366 *1	M-p   360
#	ue  }	"u	M-^A  201	M-|   374	M-v   366 *1
#	Ae  [	"A	N-^N  216	M-D   304	M-^E  205
#	Oe  \	"O	M-^Y  231	M-V   326	M-^V  226
#	Ue  ]	"U	M-^Z  232 *2	M-\   334	M-^Z  232 *2
#	ss  ~	"s	M-a   341	M-_   337	M-{   373
#
#	Anmerkungen
#	*1: Darstellung NeXT 'ue' kollidiert mit iso8859 'oe';
#	*2: Darstellung fuer 'ss' auf NeXT und ibm gleich;
#############################################################################
# Umlaut-Umwandlungsroutinen
    
sub ibm2iso {
    # ibm Umlaut nach iso Umlaut Darstellung
    local($text) = @_;
    $text =~ y/\204\224\201\216\231\232\341/\344\366\374\304\326\334\337/;
    return ($text);
}

sub next2iso {
    # NeXT Umlaut nach iso Umlaut Darstellung
    local($text) = @_;
    $text =~ y/\331\360\366\205\226\232\373/\344\366\374\304\326\334\337/;
    return ($text);
}

sub tex2iso {
    # tex Umlaut nach iso Umlaut Darstellung
    local($text) = @_;
    $text =~ s/\"a/\344/g;
    $text =~ s/\"o/\366/g;
    $text =~ s/\"u/\374/g;
    $text =~ s/\"A/\304/g;
    $text =~ s/\"O/\326/g;
    $text =~ s/\"U/\334/g;
    $text =~ s/\"s/\337/g;
    return ($text);
}

sub ascii2iso {
    # german ascii 7-bit Umlaut nach iso Umlaut Darstellung
    local($text) = @_;
    $text =~ y/{|}[\\]~/\344\366\374\304\326\334\337/;
    return ($text);
}

sub iso2ibm {
    # iso Umlaut nach ibm Umlaut Darstellung
    local($text) = @_;
    $text =~ y/\344\366\374\304\326\334\337/\204\224\201\216\231\232\341/;
    return ($text);
}

sub iso2next {
    # iso Umlaut nach NeXT Umlaut Darstellung
    local($text) = @_;
    $text =~ y/\344\366\374\304\326\334\337/\331\360\366\205\226\232\373/;
    return ($text);
}

sub iso2tex {
    # iso Umlaut nach tex Umlaut Darstellung
    local($text) = @_;
    $text =~ s/\344/\"a/g;
    $text =~ s/\366/\"o/g;
    $text =~ s/\374/\"u/g;
    $text =~ s/\304/\"A/g;
    $text =~ s/\326/\"O/g;
    $text =~ s/\334/\"U/g;
    $text =~ s/\337/\"s/g;
    return($text);
}

sub iso2ascii {
    # iso Umlaut nach german ascii 7-bit Umlaut Darstellung
    local($text) = @_;
    $text =~ y/\344\366\374\304\326\334\337/{|}[\\]~/;
    return($text);
}

sub iso2umlaut {
    # iso Umlaut nach german Umlaut Ersatzdarstellung
    local($text) = @_;
    $text =~ s/\344/ae/g;
    $text =~ s/\366/oe/g;
    $text =~ s/\374/ue/g;
    $text =~ s/\304/Ae/g;
    $text =~ s/\326/Oe/g;
    $text =~ s/\334/Ue/g;
    $text =~ s/\337/ss/g;
    return($text);
}

1;
