1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

support utf8 bom import.

This commit is contained in:
Shlomi Fish 2018-05-02 20:18:01 +03:00
parent 9ddaa7e110
commit 9eab5fe6bf
3 changed files with 23 additions and 1 deletions

View file

@ -879,7 +879,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
# Based on https://stackoverflow.com/questions/8898294 - thanks!
def mydecode(s):
if sys.version_info < (3,):
return s
pass # return s
for encoding in "utf-8-sig", "utf-8":
try:
return s.decode(encoding)

View file

@ -118,6 +118,20 @@ KD QC 5C QH 6S 3D
8S 7H 3H 2C AC 7D
''', 'import worked with Ts')
def test_import_utf8_bom(self):
return self._successful_import(
'tests/unit/data/624-with-utf8-bom.board',
'''FC: - - - -
KC 6H 4C QS 2D 4S AS
4H TH 2S JH 2H 9S AH
3S 6C 9H AD KH QD 7C
3C JS 5H KS TC 9C 8C
4D 9D 7S JC 5D TS
KD QC 5C QH 6S 3D
5S JD 8D 6D TD 8H
8S 7H 3H 2C AC 7D
''', 'import worked with utf-8 bom')
def mymain():
from pycotap import TAPTestRunner

View file

@ -0,0 +1,8 @@
: KC 6H 4C QS 2D 4S AS
: 4H TH 2S JH 2H 9S AH
: 3S 6C 9H AD KH QD 7C
: 3C JS 5H KS TC 9C 8C
: 4D 9D 7S JC 5D TS
: KD QC 5C QH 6S 3D
: 5S JD 8D 6D TD 8H
: 8S 7H 3H 2C AC 7D