Commit b39329bf authored by Aaron Jacobs's avatar Aaron Jacobs Committed by Russ Cox

unicode/utf8: don't imply that the empty string is incorrect UTF-8

Change-Id: Idd9523949ee4f2f304b12be39f8940ba34a420be
Reviewed-on: https://go-review.googlesource.com/16361Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent a150c4ff
...@@ -145,7 +145,7 @@ func FullRuneInString(s string) bool { ...@@ -145,7 +145,7 @@ func FullRuneInString(s string) bool {
// DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and // DecodeRune unpacks the first UTF-8 encoding in p and returns the rune and
// its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if // 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 // the encoding is invalid, it returns (RuneError, 1). Both are impossible
// results for correct UTF-8. // results for correct, non-empty 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
...@@ -192,7 +192,8 @@ func DecodeRune(p []byte) (r rune, size int) { ...@@ -192,7 +192,8 @@ func DecodeRune(p []byte) (r rune, size int) {
// DecodeRuneInString is like DecodeRune but its input is a string. If s is // DecodeRuneInString is like DecodeRune but its input is a string. If s is
// empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, it // empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, it
// returns (RuneError, 1). Both are impossible results for correct UTF-8. // returns (RuneError, 1). Both are impossible results for correct, non-empty
// 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
...@@ -240,7 +241,7 @@ func DecodeRuneInString(s string) (r rune, size int) { ...@@ -240,7 +241,7 @@ func DecodeRuneInString(s string) (r rune, size int) {
// DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and // DecodeLastRune unpacks the last UTF-8 encoding in p and returns the rune and
// its width in bytes. If p is empty it returns (RuneError, 0). Otherwise, if // 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 // the encoding is invalid, it returns (RuneError, 1). Both are impossible
// results for correct UTF-8. // results for correct, non-empty 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
...@@ -279,7 +280,8 @@ func DecodeLastRune(p []byte) (r rune, size int) { ...@@ -279,7 +280,8 @@ func DecodeLastRune(p []byte) (r rune, size int) {
// DecodeLastRuneInString is like DecodeLastRune but its input is a string. If // DecodeLastRuneInString is like DecodeLastRune but its input is a string. If
// s is empty it returns (RuneError, 0). Otherwise, if the encoding is invalid, // 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. // it returns (RuneError, 1). Both are impossible results for correct,
// non-empty 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
......
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