]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/Locale.pm
Weitere, nicht ganz so behutsame Codesaeuberungen.
[kivitendo-erp.git] / SL / Locale.pm
index 1e41344552f1247a2e709421f7c4d7e96a9fbbfa..2b662bf174281656f0a4cc83bbd5447610cc80a2 100644 (file)
@@ -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";
+
+      } elsif ($char eq 'r') {
+        $new_str .= "\r";
+
+      } elsif ($char eq 's') {
+        $new_str .= ' ';
+
+      } elsif ($char eq 'x') {
+        $new_str .= chr(hex(substr($str, $i + 1, 2)));
+        $i       += 2;
 
-  $str =~ s/\\x(..)/chr(hex($1))/eg;
-  $str =~ s/\\(.)/$1/g;
+      } else {
+        $new_str .= $char;
+      }
+
+      $escaped  = 0;
+
+    } elsif ($char eq '\\') {
+      $escaped  = 1;
+
+    } else {
+      $new_str .= $char;
+    }
+  }
 
-  return $str;
+  return $new_str;
 }
 
 sub _read_special_chars_file {