File: unescape

package info (click to toggle)
termrec 0.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,148 kB
  • sloc: ansic: 8,430; makefile: 181; perl: 16; sh: 15
file content (18 lines) | stat: -rwxr-xr-x 340 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env perl
use warnings;
use Encode qw(encode_utf8);

while(<>)
{
    chomp;
    s/^#.*//;
    s/\\b/\b/g;
    s/\\n/\n/g;
    s/\\e/\e/g;
    s/\\a/\a/g;
    s/\\t/\t/g;
    s/\\u([0-9a-fA-F]{4})/encode_utf8(sprintf('%c',hex($1)))/ge;
    s/\\U([0-9a-fA-F]{6})/encode_utf8(sprintf('%c',hex($1)))/ge;
    s/\\\\/\\/g;
    print;
}