sugiany / blender_mmd_tools

mmd_tools is a blender addon for importing Models and Motions of MikuMikuDance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VMD import fails if string ends with the first byte of sjis character

iRi-E opened this issue · comments

Some vmd files have a broken multibyte string which ends with the first byte of a sjis character.
Such files cause UnicodeDecodeError so the import fails.

For example, I got the following traceback when importing "こっち向いてBabyキオゴスミク.vmd":

Traceback (most recent call last):
  File "/home/irie/.config/blender/2.65/scripts/addons_extern/mmd_tools/__init__.py", line 79, in execute
    importer = import_vmd.VMDImporter(filepath=self.filepath, scale=self.scale)
  File "/home/irie/.config/blender/2.65/scripts/addons_extern/mmd_tools/import_vmd.py", line 17, in __init__
    self.__vmdFile.load(filepath=filepath)
  File "/home/irie/.config/blender/2.65/scripts/addons_extern/mmd_tools/vmd.py", line 165, in load
    self.header.load(fin)
  File "/home/irie/.config/blender/2.65/scripts/addons_extern/mmd_tools/vmd.py", line 24, in load
    self.model_name = _toShiftJisString(struct.unpack('<20s', fin.read(20))[0])
  File "/home/irie/.config/blender/2.65/scripts/addons_extern/mmd_tools/vmd.py", line 14, in _toShiftJisString
    return byteString.decode("shift_jis")
UnicodeDecodeError: 'shift_jis' codec can't decode byte 0x88 in position 18: incomplete multibyte sequence