golang语言渐入佳境[24]-string-大小写转换类函数

栏目: Go · 发布时间: 6年前

string-大小写转换类函数

package main

import (
	"fmt"
	"strings"
)

/*
1、func Title(s string) string
将字符串s每个单词首字母大写返回

2、func ToLower(s string) string
将字符串s转换成小写返回

3、func ToLowerSpecial(_case unicode.SpecialCase, s string) string
将字符串s中所有字符按_case指定的映射转换成小写返回

4、func ToTitle(s string) string
将字符串s转换成大写返回

5、func ToTitleSpecial(_case unicode.SpecialCase, s string) string
将字符串s中所有字符按_case指定的映射转换成大写返回

6、func ToUpper(s string) string
将字符串s转换成大写返回

7、func ToUpperSpecial(_case unicode.SpecialCase, s string) string
将字符串s中所有字符按_case指定的映射转换成大写返回
 */

func main() {
	TestTitle()
	TestToTitle()
	TestToLower()
	TestToUpper()
}

func TestTitle() {
	fmt.Println(strings.Title("her royal highness"))
}

func TestToTitle() {
	fmt.Println(strings.ToTitle("louD noises"))
}

//func TestToTitleSpecial() {
//}

func TestToLower() {
	fmt.Println(strings.ToLower("Gopher"))
}

//func TestToLowerSpecial() {
//
//}

func TestToUpper() {
	fmt.Println(strings.ToUpper("Gopher"))
}

//func TestToUpperSpecial() {
//
//}

golang语言渐入佳境[24]-string-大小写转换类函数


以上所述就是小编给大家介绍的《golang语言渐入佳境[24]-string-大小写转换类函数》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

计算理论导论

计算理论导论

塞普斯 / 机械工业出版社 / 2002-8 / 39.0

This book——by a noted authority and educator in the field——presents computer science theory from a uniquely intuitive,“big picture”perspective.The author grounds his clear and interesting study on ......一起来看看 《计算理论导论》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器