github.com/hirochachacha/plua@v0.0.0-20170217012138-c82f520cc725/internal/pattern/decode.go (about) 1 package pattern 2 3 import "unicode/utf8" 4 5 func _decodeByte(input string, off int) (r rune, rsize int) { 6 if len(input) == off { 7 return eos, 0 8 } 9 return rune(input[off]), 1 10 } 11 12 func _lastDecodeByte(input string, off int) (r rune, rsize int) { 13 if off == 0 { 14 return sos, 0 15 } 16 return rune(input[off-1]), 1 17 } 18 19 func _decodeRune(input string, off int) (r rune, rsize int) { 20 if len(input) == off { 21 return eos, 0 22 } 23 return utf8.DecodeRuneInString(input[off:]) 24 } 25 26 func _lastDecodeRune(input string, off int) (r rune, rsize int) { 27 if off == 0 { 28 return sos, 0 29 } 30 return utf8.DecodeLastRuneInString(input[:off]) 31 }