File: escape_sjis.pl

package info (click to toggle)
timidity 2.14.0-8.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 11,364 kB
  • sloc: ansic: 168,735; sh: 3,730; makefile: 1,405; tcl: 1,048; perl: 285; ruby: 126
file content (27 lines) | stat: -rw-r--r-- 407 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl
# escape_sjis.pl

    binmode(STDIN);
    binmode(STDOUT);

    while (read(STDIN, $buf, 1))
    {
        if ($sjis)
        {
            $sjis = 0;

            if ($buf eq "\\")
            {
                print("\\");
            }
        }
        elsif ((((ord($buf) ^ 0x20) - 0xA1) & 0xFF) < 0x3C)
        {
            $sjis = !0;
        }

        print($buf);
    }

# [EOF]