handle file encoding ascii correctly

This commit is contained in:
Dom 2019-08-13 16:25:12 +02:00
parent bd092d89dd
commit 335f5f2ac5
1 changed files with 9 additions and 0 deletions

9
bnn.go
View File

@ -6,6 +6,8 @@ import (
"os"
"strconv"
"strings"
"golang.org/x/text/encoding/charmap"
)
// Info Structure of headline
@ -145,6 +147,13 @@ func ReadBnn(r io.Reader) (Bnn, error) {
for i, line := range lines {
var item Item
// Encoding ASCII
// Example file for ASCII was provided by Paxan
// Extended ASCII has been used -> ä 132 \u0084
if strings.Split(line, ";")[2] == "0" {
line, _ = charmap.CodePage850.NewDecoder().String(line)
}
col := strings.Split(line, ";")
// Headline contains infos