Inconsistency between []rune() and utf8.DecodeRune()

75 views
Skip to first unread message

Maxim Khitrov

unread,
Jun 28, 2012, 3:22:47 PM6/28/12
to golang-nuts
Hello,

It seems that the utf8.DecodeRune function does not check whether the
decoded rune falls outside of the Unicode range. Therefore, it does
not return the expected (RuneError, 1) result for a value such as
U+1FFFFF, as in the following example:

http://play.golang.org/p/H-8QAbmYaT

Is this a bug or by design? I expected the two print calls to output
the same thing.

- Max

Rob 'Commander' Pike

unread,
Jun 28, 2012, 3:48:27 PM6/28/12
to Maxim Khitrov, golang-nuts
A bug. Please file an issue.

-rob
Reply all
Reply to author
Forward
0 new messages