Having a fun time working with special characters (musical symbols) in Go

Okay this works:

// the chord is D♭ for index :=range chordarray { var thischord string thischord = chordarray[index] log.Info("the chord is " + thischord) // terminal says "the chord is D♭" var secondcharacter string secondcharacter = thischord[1:] log.Info("secondcharacter : " + secondcharacter) //terminal says: "secondcharacter : ♭" if strings.HasPrefix(secondcharacter, "♯") || strings.HasPrefix(secondcharacter, "♭"){ log.Info("yes it is sharp or flat") //terminal says "yes it is sharp or flat" } } 

But then this turns the symbols into garbage:

var note string note = thischord[:2] log.Info("the note is " + note) // terminal says "the note is D\xe2" 

What the fuck?

I'm having no luck with google, does anybody know a solution to this or a library I can throw at it? I just need to manipulate strings with musical symbols in them without having to study fucking quantum mechanics.

Submitted March 01, 2017 at 03:30AM by trycat
via reddit http://ift.tt/2lQxIdq