On Wed, 11 Oct 2017, at 10:33 AM, Ian Davis wrote: > > On Wed, 11 Oct 2017, at 09:57 AM, Gianguido SorĂ wrote: >> >> I'm writing a small utility which uses a strings.Replacer to process >> some substitutions in some strings; these strings contains UTF-8 >> characters as well as emojis.>> >> Here you can find a playground with an example: >> https://play.golang.org/p/gdfZ_zGGiO>> >> As you can see from the playground, the occurrence of "2" has been >> replaced with the string "altered" into the emoji itself, even though >> the hex representation of it is not directly listed in the Replacer.>> >> What could I do to prevent this from happening? > > At first glance this looks like a bug in strings.Replacer. If the > string you are replacing is a single byte character then NewReplacer > uses a byteStringReplacer which treats the target as a byte array. I > suggest opening an issue here https://github.com/golang/go/issues After a bit more thought, the reason why the replacement happens is because the emoji you are using is a composite that combines the keycap image with the number 2. You can see it in this example which shows various equivalent forms of the emoji: https://play.golang.org/p/HhaNuZ3JZM
Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.