17 lines
332 B
Go
17 lines
332 B
Go
|
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
|
||
|
}
|