From 03ea97647e3fbdea4323f4f2136bdfa87cb15c1b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 31 Jan 2008 15:04:57 +0000 Subject: [PATCH] =?utf8?q?Parser=20f=C3=BCr=20besondere=20Zeichen=20in=20s?= =?utf8?q?pecial=5Fchars=20umgeschrieben.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Locale.pm | 47 ++++++++++++++++++++++++++++++++--------- locale/de/special_chars | 8 +++---- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/SL/Locale.pm b/SL/Locale.pm index 1e4134455..c182117f9 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -105,19 +105,44 @@ sub _init { } sub _handle_markup { - my $self = shift; - my $str = shift; + my $self = shift; + my $str = shift; - if ($str eq "\\n") { - return "\n"; - } elsif ($str eq "\\r") { - return "\r"; - } + my $escaped = 0; + my $new_str = ''; + + for (my $i = 0; $i < length $str; $i++) { + my $char = substr $str, $i, 1; + + if ($escaped) { + if ($char eq 'n') { + $new_str .= "\n"; - $str =~ s/\\x(..)/chr(hex($1))/eg; - $str =~ s/\\(.)/$1/g; + } elsif ($char eq 'r') { + $new_str .= "\r"; - return $str; + } elsif ($char eq 's') { + $new_str .= ' '; + + } elsif ($char eq 'x') { + $new_str .= chr(hex(substr($str, $i + 1, 2))); + $i += 2; + + } else { + $new_str .= $char; + } + + $escaped = 0; + + } elsif ($char eq '\\') { + $escaped = 1; + + } else { + $new_str .= $char; + } + } + + return $new_str; } sub _read_special_chars_file { @@ -160,6 +185,8 @@ sub _read_special_chars_file { $scmap->{order} = [ map { $self->_handle_markup($_) } split m/\s+/, $order ]; $self->{special_chars_map}->{"${format}-reverse"}->{order} = [ grep { $_ } map { $scmap->{$_} } reverse @{ $scmap->{order} } ]; } + + $main::lxdebug->dump(0, "scm", $self->{special_chars_map}); } sub text { diff --git a/locale/de/special_chars b/locale/de/special_chars index e36bcf505..5c5b0fff6 100644 --- a/locale/de/special_chars +++ b/locale/de/special_chars @@ -33,7 +33,7 @@ order=< > \n [Template/LaTeX] order=\\ & \n \r " $ % _ # ^ { } < > £ ± \xe1 ² ³ -\\=\\textbackslash +\\=\\textbackslash\s = "='' &=\\& @@ -45,12 +45,12 @@ _=\\_ }=\\} <=$<$ >=$>$ -£=\\pounds -\n=\\newline +£=\\pounds\s +\n=\\newline\s \r= ±=$\\pm$ \xe1=$\\bullet$ -^=\\^\\ +^=\\^\\\s ²=$^2$ ³=$^3$ -- 2.20.1