OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [exp/] [norm/] [input.go] - Blame information for rev 861

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package norm
6
 
7
import "unicode/utf8"
8
 
9
type input interface {
10
        skipASCII(p int) int
11
        skipNonStarter(p int) int
12
        appendSlice(buf []byte, s, e int) []byte
13
        copySlice(buf []byte, s, e int)
14
        charinfo(p int) (uint16, int)
15
        decomposeNFC(p int) uint16
16
        decomposeNFKC(p int) uint16
17
        hangul(p int) rune
18
}
19
 
20
type inputString string
21
 
22
func (s inputString) skipASCII(p int) int {
23
        for ; p < len(s) && s[p] < utf8.RuneSelf; p++ {
24
        }
25
        return p
26
}
27
 
28
func (s inputString) skipNonStarter(p int) int {
29
        for ; p < len(s) && !utf8.RuneStart(s[p]); p++ {
30
        }
31
        return p
32
}
33
 
34
func (s inputString) appendSlice(buf []byte, b, e int) []byte {
35
        for i := b; i < e; i++ {
36
                buf = append(buf, s[i])
37
        }
38
        return buf
39
}
40
 
41
func (s inputString) copySlice(buf []byte, b, e int) {
42
        copy(buf, s[b:e])
43
}
44
 
45
func (s inputString) charinfo(p int) (uint16, int) {
46
        return charInfoTrie.lookupString(string(s[p:]))
47
}
48
 
49
func (s inputString) decomposeNFC(p int) uint16 {
50
        return nfcDecompTrie.lookupStringUnsafe(string(s[p:]))
51
}
52
 
53
func (s inputString) decomposeNFKC(p int) uint16 {
54
        return nfkcDecompTrie.lookupStringUnsafe(string(s[p:]))
55
}
56
 
57
func (s inputString) hangul(p int) rune {
58
        if !isHangulString(string(s[p:])) {
59
                return 0
60
        }
61
        rune, _ := utf8.DecodeRuneInString(string(s[p:]))
62
        return rune
63
}
64
 
65
type inputBytes []byte
66
 
67
func (s inputBytes) skipASCII(p int) int {
68
        for ; p < len(s) && s[p] < utf8.RuneSelf; p++ {
69
        }
70
        return p
71
}
72
 
73
func (s inputBytes) skipNonStarter(p int) int {
74
        for ; p < len(s) && !utf8.RuneStart(s[p]); p++ {
75
        }
76
        return p
77
}
78
 
79
func (s inputBytes) appendSlice(buf []byte, b, e int) []byte {
80
        return append(buf, s[b:e]...)
81
}
82
 
83
func (s inputBytes) copySlice(buf []byte, b, e int) {
84
        copy(buf, s[b:e])
85
}
86
 
87
func (s inputBytes) charinfo(p int) (uint16, int) {
88
        return charInfoTrie.lookup(s[p:])
89
}
90
 
91
func (s inputBytes) decomposeNFC(p int) uint16 {
92
        return nfcDecompTrie.lookupUnsafe(s[p:])
93
}
94
 
95
func (s inputBytes) decomposeNFKC(p int) uint16 {
96
        return nfkcDecompTrie.lookupUnsafe(s[p:])
97
}
98
 
99
func (s inputBytes) hangul(p int) rune {
100
        if !isHangul(s[p:]) {
101
                return 0
102
        }
103
        rune, _ := utf8.DecodeRune(s[p:])
104
        return rune
105
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.