MCPcopy Create free account
hub / github.com/V2RaySSR/RealityChecker / getDisplayWidth

Function getDisplayWidth

internal/ui/display.go:119–131  ·  view source on GitHub ↗

getDisplayWidth 计算字符串的显示宽度(中文字符占2个位置)

(s string)

Source from the content-addressed store, hash-verified

117
118// getDisplayWidth 计算字符串的显示宽度(中文字符占2个位置)
119func getDisplayWidth(s string) int {
120 width := 0
121 for _, r := range s {
122 if r < 128 {
123 // ASCII字符占1个位置
124 width++
125 } else {
126 // 中文字符占2个位置
127 width += 2
128 }
129 }
130 return width
131}
132
133// PrintAdvertisement 打印广告信息
134func PrintAdvertisement() {

Callers 1

PrintBannerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected