NicknineTheEagle / Frostbite-Scripts

Python scripts for extracting Frostbite Engine assets
Other
87 stars 14 forks source link

Fix UnicodeDecodeError in ebxtoasset.py #23

Closed registered-to-post-this closed 3 years ago

registered-to-post-this commented 3 years ago

System used: Windows 10 Enterprise ver. 19042.867 (x64), Python 3.9.2 (x64) Attempting to run ebxtoasset.py on Battlefield 1 assets results in this error:

Traceback (most recent call last):

  File "D:\Frostbite-Scripts-master\frostbite3\ebxtoasset.py", line 36, in <module>
    dbx=ebx.Dbx(os.path.join(dir0,fname),ebxFolder)
  File "D:\Frostbite-Scripts-master\frostbite3\ebx.py", line 271, in __init__
    inst=self.readComplex(instanceRepeater.complexIndex,f,True)
  File "D:\Frostbite-Scripts-master\frostbite3\ebx.py", line 298, in readComplex
    cmplx.fields.append(self.readField(fieldIndex,f))
  File "D:\Frostbite-Scripts-master\frostbite3\ebx.py", line 344, in readField
    field.value=data.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xda in position 1: invalid continuation byte

Using ISO-8859-1 instead of utf-8 seems to work with both ebxtoasset.py and ebxtottext.py but I only tested the change on Battlefield 1 assets.

NicknineTheEagle commented 3 years ago

Are you absolutely sure this EBX is really using ISO 8859-1 encoding? I've put UTF-8 there because that's what was apparently used for string fields in Battlefield 3. Post the sample which throws an error here.

registered-to-post-this commented 3 years ago

Sample of an EBX that causes the above error (there may be more, this is just the first one I found): pf_cloudpatch_01.zip

NicknineTheEagle commented 3 years ago

Yeah, I can't make sense of it, it just looks like garbage data. It's definitely not ISO 8859-1, though. Needs further investigation. You should create an issue regarding this.