My task is to get a json string from request body in utf-8 and encode it to win1251, so i could save it the db in win1251.
data, err := io.ReadAll(c.Request.GetBody())
if err != nil {
panic(err)
}
enc := charmap.Windows1251.NewEncoder()
win, err := enc.Bytes(data)
if err != nil {
panic(err)
}
_, name, _ := charset.DetermineEncoding(win, "application/json")
revel.AppLog.Debug(name)
I tried this, but i'm getting win1252(( Any ideas?