Skip to content

Instantly share code, notes, and snippets.

@syossan27
Last active December 17, 2017 04:48
Show Gist options
  • Select an option

  • Save syossan27/5fae854b927d78ad006f2a8cafecb610 to your computer and use it in GitHub Desktop.

Select an option

Save syossan27/5fae854b927d78ad006f2a8cafecb610 to your computer and use it in GitHub Desktop.
func parseNonAscii(latin1Byte []byte) string {
isMarking := false
var byteBuffer []byte
for _, codePoint := range latin1Byte {
// 131は0x83の10進数表現
if codePoint == 131 {
isMarking = true
continue
}
if isMarking {
// 6bit目を反転させるために
// 0x20をXORする
invertCodePoint := codePoint ^ 32
byteBuffer = append(byteBuffer, invertCodePoint)
isMarking = false
} else {
byteBuffer = append(byteBuffer, codePoint)
}
}
return string(byteBuffer)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment