transformer.go 945 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2015 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. package precis
  5. import "golang.org/x/text/transform"
  6. // Transformer implements the transform.Transformer interface.
  7. type Transformer struct {
  8. t transform.Transformer
  9. }
  10. // Reset implements the transform.Transformer interface.
  11. func (t Transformer) Reset() { t.t.Reset() }
  12. // Transform implements the transform.Transformer interface.
  13. func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
  14. return t.t.Transform(dst, src, atEOF)
  15. }
  16. // Bytes returns a new byte slice with the result of applying t to b.
  17. func (t Transformer) Bytes(b []byte) []byte {
  18. b, _, _ = transform.Bytes(t, b)
  19. return b
  20. }
  21. // String returns a string with the result of applying t to s.
  22. func (t Transformer) String(s string) string {
  23. s, _, _ = transform.String(t, s)
  24. return s
  25. }