simple-ddl-parser icon indicating copy to clipboard operation
simple-ddl-parser copied to clipboard

Add encoding parameter to 'parse_from_file'

Open ivbeg opened this issue 3 years ago • 0 comments

Describe the bug Right now if you parse files different than the system default encoding, parse_from_file generates UnicodeDecodeError.

To Reproduce Steps to reproduce the behavior:

  1. Try this SQL file https://github.com/CollectiveIndustries/Mangos_world_database/blob/93b5bb6984237b4b359cf95610feee2671351a40/mangos/mangos_string.sql
  2. use parse_from_file(your_filepath + 'mangos_string.sql')
  3. See error UnicodeDecodeError 'charmap' codec can't decode byte 0x98 in position 3050: character maps to

Expected behavior Detect encoding using chardet or, a better way, accept encoding param to this function and pass it as the open(filename, 'r', encoding=encoding)

Desktop (please complete the following information):

  • OS: Windows 10
  • Python version: 3.10

ivbeg avatar Jul 01 '22 08:07 ivbeg