Golang strings.ToTitleSpecial() 函数的用法及示例

Golang strings.ToTitleSpecial() 函数的用法及示例

strings.ToTitleSpecial() 函数 在Golang中用于将字符串 s 中的所有Unicode字母映射为它们的Unicode标题大小写,优先考虑特殊大小写规则。

语法:

func ToTitleSpecial(c unicode.SpecialCase, s string) string
Go

在此,c是大小写映射,s是指定的字符串。

示例1:

// Golang程序演示
// strings.ToTitleSpecial函数
package main

import (
  "fmt"
  "strings"
  "unicode"
)

func main() {

  // 使用函数
  fmt.Println(strings.ToTitleSpecial(unicode.TurkishCase, "geeks for geeks"))
}
Go

输出:

GEEKS FOR GEEKS
Go

示例2:

// Golang程序演示
// strings.ToTitleSpecial函数
package main

import (
  "fmt"
  "strings"
  "unicode"
)

func main() {

  // 使用函数
  fmt.Println(strings.ToTitleSpecial(unicode.TurkishCase, "I am a student"))
}
Go

输出:

I AM A STUDENT
Go

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册