Skip to content

Instantly share code, notes, and snippets.

@C0nstantin
Created May 27, 2015 12:40
Show Gist options
  • Save C0nstantin/d211b1dfaa18bc577b92 to your computer and use it in GitHub Desktop.
Save C0nstantin/d211b1dfaa18bc577b92 to your computer and use it in GitHub Desktop.

Revisions

  1. C0nstantin created this gist May 27, 2015.
    16 changes: 16 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    import(
    "code.google.com/p/go.text/transform"
    "code.google.com/p/go.text/encoding/charmap"
    )

    func toutf8(str string) string {
    sr := strings.NewReader(str)
    tr := transform.NewReader(sr, charmap.Windows1251.NewDecoder())
    buf, err := ioutil.ReadAll(tr)
    if err != nil {
    // обработка ошибки
    }

    s := string(buf) //text в utf8
    return s;
    }