×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang bytes.ToLowerSpecial() Function with Examples

Golang | bytes.ToLowerSpecial() Function: Here, we are going to learn about the ToLowerSpecial() function of the bytes package with its usages, syntax, and examples.
Submitted by IncludeHelp, on September 26, 2021

bytes.ToLowerSpecial()

The ToLowerSpecial() function is an inbuilt function of the bytes package which is used to get a copy with all the Unicode letters of the byte slice (s – treated as UTF-8-encoded bytes ) mapped to their lower case, giving priority to the special casing rules.

It accepts two parameters (c unicode.SpecialCase, s []byte) and returns a copy with all the Unicode letters mapped to their lower case.

Syntax

func ToLowerSpecial(c unicode.SpecialCase, s []byte) []byte

Parameters

  • c : Special case.
  • s : The byte slice to be used to create a copy of the lowercase byte slice.

Return Value

The return type of the bytes.ToLowerSpecial() function is a []byte, it returns a copy with all the Unicode letters mapped to their lower case.

Example 1

// Golang program to demonstrate the
// example of bytes.ToLowerSpecial() function

package main

import (
	"bytes"
	"fmt"
	"unicode"
)

func main() {
	fmt.Printf("%s\n",
		bytes.ToLowerSpecial(
			unicode.AzeriCase, []byte("Every moment is a fresh beginning.")))
	fmt.Printf("%s\n",
		bytes.ToLowerSpecial(
			unicode.AzeriCase, []byte("Her an yeni bir başlangıçtır.")))
	fmt.Printf("%s\n",
		bytes.ToLowerSpecial(
			unicode.AzeriCase, []byte("Be so good they can't ignore you.")))
}

Output:

every moment is a fresh beginning.
her an yeni bir başlangıçtır.
be so good they can't ignore you.

Example 2

// Golang program to demonstrate the
// example of bytes.ToLowerSpecial() function

package main

import (
	"bytes"
	"fmt"
	"unicode"
)

func main() {
	var str []byte
	var result []byte

	str = []byte("Every moment is a fresh beginning.")
	result = bytes.ToLowerSpecial(unicode.AzeriCase, str)
	fmt.Printf("Original string: %s\n", str)
	fmt.Printf("Lowercase string: %s\n", result)
	fmt.Println()

	str = []byte("Her an yeni bir başlangıçtır.")
	result = bytes.ToLowerSpecial(unicode.AzeriCase, str)
	fmt.Printf("Original string: %s\n", str)
	fmt.Printf("Lowercase string: %s\n", result)
	fmt.Println()

	str = []byte("SELAM DÜNYA.")
	result = bytes.ToLowerSpecial(unicode.AzeriCase, str)
	fmt.Printf("Original string: %s\n", str)
	fmt.Printf("Lowercase string: %s\n", result)
}

Output:

Original string: Every moment is a fresh beginning.
Lowercase string: every moment is a fresh beginning.

Original string: Her an yeni bir başlangıçtır.
Lowercase string: her an yeni bir başlangıçtır.

Original string: SELAM DÜNYA.
Lowercase string: selam dünya.

Golang bytes Package »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.