pcgamedb/utils/decoder.go

17 lines
332 B
Go
Raw Normal View History

2024-12-10 08:37:16 -05:00
package utils
import (
"bytes"
"io"
"golang.org/x/text/encoding/htmlindex"
"golang.org/x/text/transform"
)
func Windows1251ToUTF8(b []byte) []byte {
decoder, _ := htmlindex.Get("windows-1251")
reader := transform.NewReader(bytes.NewReader(b), decoder.NewDecoder().Transformer)
body, _ := io.ReadAll(reader)
return body
}