benhoyt / goawk

A POSIX-compliant AWK interpreter written in Go, with CSV support
https://benhoyt.com/writings/goawk/
MIT License
1.95k stars 84 forks source link

When running "gawk --posix", ensure we're using UTF-8 #174

Closed benhoyt closed 1 year ago

benhoyt commented 1 year ago

This avoids the following test failure when LC_ALL=C:

$ go test ./interp
--- FAIL: TestInterp (1.80s)
    --- FAIL: TestInterp/awkposix_BEGIN_{_RS="ö"_}__{_print_}__#_!windows-gawk (0.00s)
        interp_test.go:983: expected/got:
            "1\ntwo\nthree\n"
            "1\n\xb6two\n\xb6three\n"
FAIL
FAIL    github.com/benhoyt/goawk/interp 1.874s
FAIL

Also make the same change in goawk_test.go to avoid issues in future (though that doesn't fail right now).

Thanks to Jan Mercl for the bug report.