headzoo / surf

Stateful programmatic web browsing in Go.
MIT License
1.48k stars 159 forks source link

Some problems with encoding. #30

Closed errashe closed 9 years ago

errashe commented 9 years ago

Hello from Russia! I'am gonna try to use golang instead ruby (mechanize). But now i have a problem with encoding. When i trying to get some page (ex. http://google.com/) - i got some words on Russian like a diamond with a question. What i should to do?

P.S. I tryed to change response to utf-8 and cp1251...

Problem code;

a := surf.NewBrowser()
a.Open("http://google.com/")
fmt.Println(a.Body()) // For example

and here i have bad characters.

cornerot commented 9 years ago

Привет, коллега. Да, действительно, есть такая проблема. Сегодня-завтра постараюсь глянуть в чём дело.

cornerot commented 9 years ago

Проблема не в surf, а в кодировке, в которой отдаёт google. К примеру:

a := surf.NewBrowser()
a.Open("http://mail.ru/")
fmt.Println(a.Body())

отработает нормально.

А вот собственно причина:

curl www.google.ru | iconv -f cp1251 -t utf8
cornerot commented 9 years ago

Hello, headzoo. You can close this issue.

errashe commented 9 years ago

10/10. Спасибо большое!

cornerot commented 9 years ago

Пожалуйста!