...
1
2
3
4
5
6 package internal
7
8 import (
9 "golang.org/x/text/encoding"
10 "golang.org/x/text/encoding/internal/identifier"
11 "golang.org/x/text/transform"
12 )
13
14
15
16 type Encoding struct {
17 encoding.Encoding
18 Name string
19 MIB identifier.MIB
20 }
21
22
23 var _ identifier.Interface = (*Encoding)(nil)
24
25 func (e *Encoding) String() string {
26 return e.Name
27 }
28
29 func (e *Encoding) ID() (mib identifier.MIB, other string) {
30 return e.MIB, ""
31 }
32
33
34 type SimpleEncoding struct {
35 Decoder transform.Transformer
36 Encoder transform.Transformer
37 }
38
39 func (e *SimpleEncoding) NewDecoder() *encoding.Decoder {
40 return &encoding.Decoder{Transformer: e.Decoder}
41 }
42
43 func (e *SimpleEncoding) NewEncoder() *encoding.Encoder {
44 return &encoding.Encoder{Transformer: e.Encoder}
45 }
46
47
48
49 type FuncEncoding struct {
50 Decoder func() transform.Transformer
51 Encoder func() transform.Transformer
52 }
53
54 func (e FuncEncoding) NewDecoder() *encoding.Decoder {
55 return &encoding.Decoder{Transformer: e.Decoder()}
56 }
57
58 func (e FuncEncoding) NewEncoder() *encoding.Encoder {
59 return &encoding.Encoder{Transformer: e.Encoder()}
60 }
61
62
63
64
65 type RepertoireError byte
66
67
68 func (r RepertoireError) Error() string {
69 return "encoding: rune not supported by encoding."
70 }
71
72
73 func (r RepertoireError) Replacement() byte { return byte(r) }
74
75 var ErrASCIIReplacement = RepertoireError(encoding.ASCIISub)
76
View as plain text