Skip to content

Incorrect decoding of compressed characters #31

@eidrisov

Description

@eidrisov

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions