Add utf-8 encoding
This commit is contained in:
parent
d29700239b
commit
cf8abfaa95
1 changed files with 4 additions and 3 deletions
7
SSnR.py
7
SSnR.py
|
@ -105,7 +105,7 @@ def main():
|
||||||
return -1
|
return -1
|
||||||
for input_filename in filenames:
|
for input_filename in filenames:
|
||||||
try:
|
try:
|
||||||
output_file = open((input_ex.subn(args["regex_output"], input_filename))[0], "w")
|
output_file = open((input_ex.subn(args["regex_output"], input_filename))[0], "w", encoding='utf8')
|
||||||
output_files.append(output_file)
|
output_files.append(output_file)
|
||||||
except OSError as exception:
|
except OSError as exception:
|
||||||
print("Error: file not found: " + str(exception))
|
print("Error: file not found: " + str(exception))
|
||||||
|
@ -113,7 +113,7 @@ def main():
|
||||||
use_output_file = True
|
use_output_file = True
|
||||||
elif args["output"] is not None:
|
elif args["output"] is not None:
|
||||||
try:
|
try:
|
||||||
output_file = open(args["output"], "w")
|
output_file = open(args["output"], "w", encoding='utf8')
|
||||||
output_files.append(output_file)
|
output_files.append(output_file)
|
||||||
except OSError as exception:
|
except OSError as exception:
|
||||||
print("Error: file not found: " + str(exception))
|
print("Error: file not found: " + str(exception))
|
||||||
|
@ -127,7 +127,7 @@ def main():
|
||||||
if is_file:
|
if is_file:
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
try:
|
try:
|
||||||
with open(filename, "r") as file:
|
with open(filename, "r", encoding='utf8') as file:
|
||||||
string = file.read()
|
string = file.read()
|
||||||
except OSError as exception:
|
except OSError as exception:
|
||||||
print("Error: file not found: " + str(exception))
|
print("Error: file not found: " + str(exception))
|
||||||
|
@ -240,3 +240,4 @@ def find_line(begin_pos, end_pos, new_lines):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue