diff --git a/pydelta/PyDelta.py b/pydelta/PyDelta.py index 3a68124..ca224a6 100644 --- a/pydelta/PyDelta.py +++ b/pydelta/PyDelta.py @@ -4,6 +4,7 @@ # Annotation string references are currently broken import argparse +import locale from dataclasses import dataclass @@ -78,13 +79,17 @@ def obfuscate_cli(): parser.add_argument('--no-refactor-names', action='store_false', help='Disables refactoring variable, function and args names.') parser.add_argument('--no-encrypt-str', action='store_false', help='Disables encrypting strings.') parser.add_argument('--no-compress-encrypt', action='store_false', help='Disables compression and encryption of the code.') + parser.add_argument('--utf-8', action='store_false', help='Use encoding=utf-8 to read input file.') parser.add_argument('--str-encryption-amount', type=int, default=3, help='Amount of times to encrypt strings.') parser.add_argument('--compress-encrypt-amount', type=int, default=30, help='Amount of times to compress and encrypt the code.') args = parser.parse_args() try: - with open(args.input_file, 'r') as infile: + my_encoding = locale.getpreferredencoding() + if args.utf_8: + my_encoding = 'utf-8' + with open(args.input_file, 'r', encoding=my_encoding) as infile: source_code = infile.read() except Exception as e: raise Exception(f"Could not read input file: {str(e)}") @@ -105,4 +110,4 @@ def obfuscate_cli(): with open(args.output_file, 'w') as outfile: outfile.write(obfuscated_code) except Exception as e: - raise Exception(f"Could not write to file: {str(e)}") \ No newline at end of file + raise Exception(f"Could not write to file: {str(e)}")