mefistotelis / pylabview

Python reader of LabVIEW RSRC files (VI, CTL, LLB). File format description on the Wiki.
MIT License
86 stars 24 forks source link

Fixing version parsing for files saved with non-English LabVIEW versions #11

Closed marcpage closed 1 year ago

marcpage commented 1 year ago

I noticed that files saved from a non-English LabVIEW raise exceptions. It turns out there is a two-byte language integer right after the version, where English is 0 (hence why many people wouldn't see a problem with the existing code).

I removed the version_text field and replaced it with a language field. To allow backwards-compatibility, I kept the getVerText method and added a getVerLanguage method.

This now prevents exceptions from being thrown on an extensive list of LabVIEW files I have.

This has been observed in files saved in version 19.0.0f5 with language codes of 14 (Japanese) and 33 (Chinese).

Also found in: 8.0.0f5 (Language = 3, possibly German, see note below), 10.0.0f32, 12.0.0f24, 17.0.0f5, 17.0.1f2

It appears that these codes hearken back to the old Macintosh headers.

marcpage commented 1 year ago

I cannot make changes to the bottom of the Blocks wiki page.

I think the relevant changes from this PR are:

Length | Type | Value --------+---------+------- 4 | uint32 | Version Bits 2 | uint16 | Language (English = 0) 1 | uint8 | String length

mefistotelis commented 1 year ago

Looks ok. Could you add info about LabVIEW version(s) where it was noticed, to the commit comment? This will make sure there is no confusion in case it turns out in some versions there is a text.

marcpage commented 1 year ago

Notes added.

marcpage commented 1 year ago

Also found in: 8.0.0f5 (Language = 3, not sure what language that is), 10.0.0f32, 17.0.0f5, 17.0.1f2