0

I am trying to convert string PyrÉnÉes to Pyrenees in Go but I am getting Pyr�n�es as output.

package main

import (
    "fmt"
    "unicode/utf8"
)

func main() {
    s := "PyrÉnÉes"
    t := make([]byte, utf8.RuneCountInString(s))
    i := 0
    for _, r := range s {
        t[i] = byte(r)
        i++
    }
    fmt.Print(string(t))
}

Run Here

Can someone advise what wrong I am doing ?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
ganesh.go
  • 39
  • 8

0 Answers0