Menu Close

Go – CaseRange type in unicode package in go

Here, We will learn about CaseRange type in unicode package in go. CaseRange type in unicode package in go shows la range of Unicode code points for simple case conversion in go golang.

Type prototype

type CaseRange struct {
Lo uint32
Hi uint32
Delta d
}

The range runs from Lo to Hi inclusive. Here, Deltas are the number to add to the code point to reach the code point for a different case for that character. Deltas can be negative but If it is zero then it means the character is in the corresponding case.

Example with code:

package main

import (
  "fmt"
  "unicode"
)

func main() {
  x := unicode.TurkishCase

  const l_ci = 'a'

  fmt.Printf("%#U\n", x.ToLower(l_ci))
  fmt.Printf("%#U\n", x.ToTitle(l_ci))
  fmt.Printf("%#U\n", x.ToUpper(l_ci))

  const u_ci = 'A'
  fmt.Printf("%#U\n", x.ToLower(u_ci))
  fmt.Printf("%#U\n", x.ToTitle(u_ci))
  fmt.Printf("%#U\n", x.ToUpper(u_ci))

}

Output:

U+0061 'a' 
U+0041 'A'
U+0041 'A'
U+0061 'a'
U+0041 'A'
U+0041 'A'

To learn more about golang, Please refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

https://golang.org/doc/
https://golang.org/pkg/
Posted in golang, unicode

Leave a Reply

Your email address will not be published.

Contact Us