Last active
December 17, 2017 04:48
-
-
Save syossan27/5fae854b927d78ad006f2a8cafecb610 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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