Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect decoding of compressed characters #31

Open
eidrisov opened this issue Nov 17, 2023 · 0 comments
Open

Incorrect decoding of compressed characters #31

eidrisov opened this issue Nov 17, 2023 · 0 comments

Comments

@eidrisov
Copy link

eidrisov commented Nov 17, 2023

Decoding of compressed characters is not handled correclty:

func (r *LabelBIFF8) GetString() string {
	if int(r.grbit[0]) == 1 {
		name := helpers.BytesToUints16(r.rgb[:])
		runes := utf16.Decode(name)
		return string(runes)
	} else {
		return string(decodeWindows1251(r.rgb[:]))
	}
}

The code outputs incorrect result: Hinterfьllmaterial Ш 6 mm
Expected output Hinterfüllmaterial Ø 6 mm

Each compressed character(byte) has to be converted into unit16 and then decoded.
The line return string(decodeWindows1251(r.rgb[:])) should be replaced with:

name := []uint16{}
for _, b := range r.rgb[:] {
   name = append(name, uint16(b))
}
runes := utf16.Decode(name)
return string(runes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant