Specific encoding read methods
(buf *ByteBuffer, size int, err *Error)
| 74 | |
| 75 | // Specific encoding read methods |
| 76 | func readLatin1(buf *ByteBuffer, size int, err *Error) string { |
| 77 | data := buf.ReadBinary(size, err) |
| 78 | if err.HasError() { |
| 79 | return "" |
| 80 | } |
| 81 | // Latin1 bytes need to be converted to UTF-8 |
| 82 | // Each Latin1 byte is a single Unicode code point (0-255) |
| 83 | runes := make([]rune, size) |
| 84 | for i, b := range data { |
| 85 | runes[i] = rune(b) |
| 86 | } |
| 87 | return string(runes) |
| 88 | } |
| 89 | |
| 90 | func readUTF16LE(buf *ByteBuffer, byteCount int, err *Error) string { |
| 91 | if byteCount&1 != 0 { |