Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

Commit

Permalink
去掉字符串尾部的结束标记以免输出时乱码
Browse files Browse the repository at this point in the history
  • Loading branch information
chen.s.g committed Jan 31, 2019
1 parent d99e08e commit 4b12dad
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions workbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ func (w *WorkBook) parseString(buf io.ReadSeeker, size uint16, from string) (res
w.continue_utf16 = 1
}

if i > 1 && 0 == bts[i-1] {
i--
}

res = string(utf16.Decode(bts[:i]))
} else {
var n int
Expand All @@ -255,6 +259,10 @@ func (w *WorkBook) parseString(buf io.ReadSeeker, size uint16, from string) (res
err = io.EOF
}

if n > 1 && 0 == bts[n-1] {
n--
}

var bts1 = make([]uint16, n)
for k, v := range bts[:n] {
bts1[k] = uint16(v)
Expand Down

0 comments on commit 4b12dad

Please sign in to comment.