gunyarakun / python-shogi

A pure Python shogi library with move generation and validation and handling of common formats.
GNU General Public License v3.0
179 stars 43 forks source link

KIF parser encoding #34

Closed sokah2412 closed 3 years ago

sokah2412 commented 3 years ago

Hello,

I'm using your kif parser for a personal project, and I saw that you read in different encodings, depending the kifu extension (e.g. if the kifu ends with .kif, it will be read in cp932 and if it ends with .kifu, it will be read in utf-8). Is there a reason to not read every kifu file in utf-8? And why choose cp932 for .kif ? I find it a little bit annoying because 81dojo export kifus in utf-8, with .kif extension, so the parser crash on them. This can be fix just by renaming the file in xxxxx.kifu (and by changing the MOVE_RE regex a little bit, as proposed in a PR).

Thank you very much :)

gunyarakun commented 3 years ago

@sokah2412 Thank you for your comment, and sorry for my late response. After merging the PR modifying MOVE_RE, I've also added auto encoding detection logic. It will help us to parse 81Dojo's KIF files.