Converting a unicode literal to a rune

181 views
Skip to first unread message

Frank Schröder

unread,
Dec 11, 2013, 11:49:03 PM12/11/13
to golan...@googlegroups.com
I need to convert a unicode literal (\uXXXX) to a rune but I only have a slice of runes representing the digits, e.g. for \u00E4 I have {0x30, 0x30, 0x45, 0x34}. To get to the rune I first use strconv.Unquote() to convert the literal into a string which contains the rune and then utf8.DecodeRuneInString() to get the actual rune. 


This seems a bit convoluted. Is there a better way to do this?

Frank
Message has been deleted

Frank Schröder

unread,
Dec 12, 2013, 3:02:00 AM12/12/13
to golan...@googlegroups.com
Works. Slick. Thanks :)

Frank 

roger peppe

unread,
Dec 12, 2013, 6:18:49 AM12/12/13
to Frank Schröder, golang-nuts
It also works with []rune. http://play.golang.org/p/00gZY4N678


On 12 December 2013 08:02, Frank Schröder <frank.s...@gmail.com> wrote:
> Works. Slick. Thanks :)
>
> Frank
>
> --
> 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...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages