Fix
This commit is contained in:
1 parent
486502852e
commit
0e48ea427b
23 files changed
+386
-78
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/csv"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUTF8CSVWriterPreservesSlovenianText(t *testing.T) {
|
||||
var b bytes.Buffer
|
||||
w, err := newUTF8CSVWriter(&b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := w.Write([]string{"Opis", "Žarnica, črpalka, šoba"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
w.Flush()
|
||||
if err := w.Error(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !bytes.HasPrefix(b.Bytes(), []byte("\ufeff")) {
|
||||
t.Fatalf("no UTF-8 BOM: %v", b.Bytes())
|
||||
}
|
||||
rows, err := csv.NewReader(bytes.NewReader(bytes.TrimPrefix(b.Bytes(), []byte("\ufeff")))).ReadAll()
|
||||
if err != nil || len(rows) != 1 || rows[0][1] != "Žarnica, črpalka, šoba" {
|
||||
t.Fatalf("round trip failed: %v: %v", rows, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user