summaryrefslogtreecommitdiff
path: root/reencode.go
diff options
context:
space:
mode:
Diffstat (limited to 'reencode.go')
-rw-r--r--reencode.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/reencode.go b/reencode.go
index f18888c..d8cdb71 100644
--- a/reencode.go
+++ b/reencode.go
@@ -165,14 +165,14 @@ func (enc *ReEncoder) Write(p []byte) (int, error) {
c, size := utf8.DecodeRune(enc.buf[:])
n += size - enc.bufLen
enc.bufLen = 0
- enc.handleRune(c)
+ enc.handleRune(c, size)
if enc.err != nil {
return 0, enc.err
}
}
for utf8.FullRune(p[n:]) {
c, size := utf8.DecodeRune(p[n:])
- enc.handleRune(c)
+ enc.handleRune(c, size)
if enc.err != nil {
return n, enc.err
}
@@ -194,14 +194,14 @@ func (enc *ReEncoder) WriteString(p string) (int, error) {
c, size := utf8.DecodeRune(enc.buf[:])
n += size - enc.bufLen
enc.bufLen = 0
- enc.handleRune(c)
+ enc.handleRune(c, size)
if enc.err != nil {
return 0, enc.err
}
}
for utf8.FullRuneInString(p[n:]) {
c, size := utf8.DecodeRuneInString(p[n:])
- enc.handleRune(c)
+ enc.handleRune(c, size)
if enc.err != nil {
return n, enc.err
}
@@ -253,7 +253,7 @@ func (enc *ReEncoder) Close() error {
return nil
}
-func (enc *ReEncoder) handleRune(c rune) {
+func (enc *ReEncoder) handleRune(c rune, size int) {
rehandle:
t, err := enc.par.HandleRune(c)
if err != nil {
@@ -283,7 +283,7 @@ rehandle:
}
}
- enc.inputPos += int64(utf8.RuneLen(c))
+ enc.inputPos += int64(size)
}
// semi-public API /////////////////////////////////////////////////////////////