You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

54 lines
933 B

  1. // Copyright 2014 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 cases_test
  5. import (
  6. "fmt"
  7. "golang.org/x/text/cases"
  8. "golang.org/x/text/language"
  9. )
  10. func Example() {
  11. src := []string{
  12. "hello world!",
  13. "i with dot",
  14. "'n ijsberg",
  15. "here comes O'Brian",
  16. }
  17. for _, c := range []cases.Caser{
  18. cases.Lower(language.Und),
  19. cases.Upper(language.Turkish),
  20. cases.Title(language.Dutch),
  21. cases.Title(language.Und, cases.NoLower),
  22. } {
  23. fmt.Println()
  24. for _, s := range src {
  25. fmt.Println(c.String(s))
  26. }
  27. }
  28. // Output:
  29. // hello world!
  30. // i with dot
  31. // 'n ijsberg
  32. // here comes o'brian
  33. //
  34. // HELLO WORLD!
  35. // İ WİTH DOT
  36. // 'N İJSBERG
  37. // HERE COMES O'BRİAN
  38. //
  39. // Hello World!
  40. // I With Dot
  41. // 'n IJsberg
  42. // Here Comes O'brian
  43. //
  44. // Hello World!
  45. // I With Dot
  46. // 'N Ijsberg
  47. // Here Comes O'Brian
  48. }