Project

General

Profile

« Previous | Next » 

Revision 9784

bin/repl: support Unicode characters in the matched portion of the string

View differences:

bin/repl
11 11

  
12 12
import maps
13 13
import opts
14
import strings
14 15

  
15 16
def main():
16 17
    env_names = []
......
41 42
            repls.append((r'(?m)'+in_, out))
42 43
    stream.close()
43 44
    def repl_all(str_):
45
        str_ = strings.ustr(str_)
44 46
        for repl, with_ in repls: str_ = re.sub(repl, with_, str_)
45 47
        return str_
46 48
    
......
53 55
        for row in reader:
54 56
            row[col_num] = repl_all(row[col_num])
55 57
            writer.writerow(row)
56
    else: sys.stdout.write(repl_all(sys.stdin.read()))
58
    else: sys.stdout.write(strings.to_raw_str(repl_all(sys.stdin.read())))
57 59

  
58 60
main()

Also available in: Unified diff