xnuinside/simple-ddl-parser

Add encoding parameter to 'parse_from_file'

ivbeg opened this issue · 1 comments

ivbeg commented

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

added in 0.31.2 version #217, not sure why I didn't add it early..