R
R
Roman Rakzin2015-07-18 13:08:36
go
Roman Rakzin, 2015-07-18 13:08:36

Encoding problem in go?

Good afternoon. When I load the application, I load a list of people from the database. Then, when a person logs in, id, FIO, ... (Cyrillic) are entered into his session.
When I take the FIO value from the session, I get abracadabra. Encoding of all files is UTF-8 (tried ANSI Windows too).
Fetch data
session, _ := store.Get(r, "SessionId")
Id := session.Values["Id"].(int)
FIO := session.Values["FIO"].(string)
Role := session.Values["Role"].(string)
log.Println(
"Client connected socket=", Soc_Id, ".id-", Id, "Name-", FIO,
"Role-", Role) // Console prints "normal data"
fmt.Fprintln(w, "Hello",
Poidee, if normal values ​​​​are written to the session, and hieroglyphs come out from there, does it mean to dig somewhere there?
I even took gopath and found a package of sessions and saved each file there in UTF-8 (with and without Bom) - hieroglyphs anyway.
Where to change the encoding or what to do in this situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Rakzin, 2015-07-18
@TwoRS

I decided
w.Header().Set("Content-type", "text/html; charset=utf-8") - this is to write before the output. The file must be encoded in UTF-8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question