SRserves85 / avro-to-python

Light tool for compiling avro schema files (.avsc) to python classes
MIT License
25 stars 19 forks source link

Encoding selection not supported #31

Closed fmiguelez closed 1 year ago

fmiguelez commented 1 year ago

When trying to process avsc encoded as UTF-8 in windows following error is thrown (if non-ascii characters are present):

    Traceback (most recent call last):
      File "O:\ws\mdp\avro-to-python\venv\Scripts\avro-to-python-script.py", line 33, in <module>
        sys.exit(load_entry_point('avro-to-python', 'console_scripts', 'avro-to-python')())
      File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\click\core.py", line 1128, in __call__
        return self.main(*args, **kwargs)
      File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\click\core.py", line 1053, in main
        rv = self.invoke(ctx)
      File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\click\core.py", line 1395, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\click\core.py", line 754, in invoke
        return __callback(*args, **kwargs)
      File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\avro_to_python\cli.py", line 34, in main
        reader.read()
      File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\avro_to_python\reader\read.py", line 80, in read
        self._read_files()
      File "O:\ws\mdp\avro-to-python\venv\lib\site-packages\avro_to_python\reader\read.py", line 125, in _read_files
        serialized = json.load(f)
      File "C:\Users\miguelez\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 293, in load
        return loads(fp.read(),
      File "C:\Users\miguelez\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 41600: character maps to <undefined>