summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/text/encoding/korean
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-05-11 21:54:32 +0200
committerWim <wim@42.be>2018-05-11 21:54:32 +0200
commitbf0b9959d1b81d6362a390baaee70f2102fb2d58 (patch)
tree61f2e71367884883cb9f68d7ac55cdcbb5dce908 /vendor/golang.org/x/text/encoding/korean
parent406a54b597271add1e297231e6f260895eff8f1d (diff)
downloadmatterbridge-msglm-bf0b9959d1b81d6362a390baaee70f2102fb2d58.tar.gz
matterbridge-msglm-bf0b9959d1b81d6362a390baaee70f2102fb2d58.tar.bz2
matterbridge-msglm-bf0b9959d1b81d6362a390baaee70f2102fb2d58.zip
Add vendor github.com/dfordsoft/golib/ic
Diffstat (limited to 'vendor/golang.org/x/text/encoding/korean')
-rw-r--r--vendor/golang.org/x/text/encoding/korean/euckr.go39
1 files changed, 19 insertions, 20 deletions
diff --git a/vendor/golang.org/x/text/encoding/korean/euckr.go b/vendor/golang.org/x/text/encoding/korean/euckr.go
index a4b9ff17..034337f5 100644
--- a/vendor/golang.org/x/text/encoding/korean/euckr.go
+++ b/vendor/golang.org/x/text/encoding/korean/euckr.go
@@ -5,7 +5,6 @@
package korean
import (
- "errors"
"unicode/utf8"
"golang.org/x/text/encoding"
@@ -26,8 +25,6 @@ var eucKR = internal.Encoding{
identifier.EUCKR,
}
-var errInvalidEUCKR = errors.New("korean: invalid EUC-KR encoding")
-
type eucKRDecoder struct{ transform.NopResetter }
func (eucKRDecoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
@@ -40,10 +37,15 @@ loop:
case 0x81 <= c0 && c0 < 0xff:
if nSrc+1 >= len(src) {
- err = transform.ErrShortSrc
- break loop
+ if !atEOF {
+ err = transform.ErrShortSrc
+ break loop
+ }
+ r, size = utf8.RuneError, 1
+ break
}
c1 := src[nSrc+1]
+ size = 2
if c0 < 0xc7 {
r = 178 * rune(c0-0x81)
switch {
@@ -54,39 +56,36 @@ loop:
case 0x81 <= c1 && c1 < 0xff:
r += rune(c1) - (0x81 - 2*26)
default:
- err = errInvalidEUCKR
- break loop
+ goto decError
}
} else if 0xa1 <= c1 && c1 < 0xff {
r = 178*(0xc7-0x81) + rune(c0-0xc7)*94 + rune(c1-0xa1)
} else {
- err = errInvalidEUCKR
- break loop
+ goto decError
}
if int(r) < len(decode) {
r = rune(decode[r])
- if r == 0 {
- r = '\ufffd'
+ if r != 0 {
+ break
}
- } else {
- r = '\ufffd'
}
- size = 2
+ decError:
+ r = utf8.RuneError
+ if c1 < utf8.RuneSelf {
+ size = 1
+ }
default:
- err = errInvalidEUCKR
- break loop
+ r, size = utf8.RuneError, 1
+ break
}
if nDst+utf8.RuneLen(r) > len(dst) {
err = transform.ErrShortDst
- break loop
+ break
}
nDst += utf8.EncodeRune(dst[nDst:], r)
}
- if atEOF && err == transform.ErrShortSrc {
- err = errInvalidEUCKR
- }
return nDst, nSrc, err
}