Commit 2dcb6138 authored by Nigel Tao's avatar Nigel Tao

unicode/utf8: fix docs for DecodeRune(empty) and friends.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/157080043
parent 343d1136
...@@ -211,8 +211,11 @@ func FullRuneInString(s string) bool { ...@@ -211,8 +211,11 @@ func FullRuneInString(s string) bool {
return !short return !short
} }
// DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and its width in bytes. // DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and
// If the encoding is invalid, it returns (RuneError, 1), an impossible result for correct UTF-8. // its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if
// the encoding is invalid, it returns (RuneError, 1). Both are impossible
// results for correct UTF-8.
//
// An encoding is invalid if it is incorrect UTF-8, encodes a rune that is // An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
// out of range, or is not the shortest possible UTF-8 encoding for the // out of range, or is not the shortest possible UTF-8 encoding for the
// value. No other validation is performed. // value. No other validation is performed.
...@@ -221,8 +224,10 @@ func DecodeRune(p []byte) (r rune, size int) { ...@@ -221,8 +224,10 @@ func DecodeRune(p []byte) (r rune, size int) {
return return
} }
// DecodeRuneInString is like DecodeRune but its input is a string. // DecodeRuneInString is like DecodeRune but its input is a string. If s is
// If the encoding is invalid, it returns (RuneError, 1), an impossible result for correct UTF-8. // empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, it
// returns (RuneError, 1). Both are impossible results for correct UTF-8.
//
// An encoding is invalid if it is incorrect UTF-8, encodes a rune that is // An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
// out of range, or is not the shortest possible UTF-8 encoding for the // out of range, or is not the shortest possible UTF-8 encoding for the
// value. No other validation is performed. // value. No other validation is performed.
...@@ -231,8 +236,11 @@ func DecodeRuneInString(s string) (r rune, size int) { ...@@ -231,8 +236,11 @@ func DecodeRuneInString(s string) (r rune, size int) {
return return
} }
// DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and its width in bytes. // DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and
// If the encoding is invalid, it returns (RuneError, 1), an impossible result for correct UTF-8. // its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if
// the encoding is invalid, it returns (RuneError, 1). Both are impossible
// results for correct UTF-8.
//
// An encoding is invalid if it is incorrect UTF-8, encodes a rune that is // An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
// out of range, or is not the shortest possible UTF-8 encoding for the // out of range, or is not the shortest possible UTF-8 encoding for the
// value. No other validation is performed. // value. No other validation is performed.
...@@ -268,8 +276,10 @@ func DecodeLastRune(p []byte) (r rune, size int) { ...@@ -268,8 +276,10 @@ func DecodeLastRune(p []byte) (r rune, size int) {
return r, size return r, size
} }
// DecodeLastRuneInString is like DecodeLastRune but its input is a string. // DecodeLastRuneInString is like DecodeLastRune but its input is a string. If
// If the encoding is invalid, it returns (RuneError, 1), an impossible result for correct UTF-8. // s is empty it returns (RuneError, 0). Otherwise, if the encoding is invalid,
// it returns (RuneError, 1). Both are impossible results for correct UTF-8.
//
// An encoding is invalid if it is incorrect UTF-8, encodes a rune that is // An encoding is invalid if it is incorrect UTF-8, encodes a rune that is
// out of range, or is not the shortest possible UTF-8 encoding for the // out of range, or is not the shortest possible UTF-8 encoding for the
// value. No other validation is performed. // value. No other validation is performed.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment