我的问题是,如何能在 Unicode 中也获得结果 5?
更新: 找到了一个方法
Code: Select all
MsgBox, % StrLenA("1全角")
StrLenA(string) { ; 注: 不太正确,全角符号不能计算为2
Loop, Parse, string
len += ( Asc(A_LoopField) < 0x2E80 or Asc(A_LoopField) > 0x9FFF ) ? 1 : 2
Return len
}
Moderators: tmplinshi, arcticir
Code: Select all
MsgBox, % StrLenA("1全角")
StrLenA(string) { ; 注: 不太正确,全角符号不能计算为2
Loop, Parse, string
len += ( Asc(A_LoopField) < 0x2E80 or Asc(A_LoopField) > 0x9FFF ) ? 1 : 2
Return len
}
Code: Select all
MsgBox, % StrLen(regexreplace("1全角","[^\x00-\xff]","11"))
Code: Select all
StrLenA(str) {
Return DllCall("MSVCRT.DLL\strlen", "AStr", str)
}
Code: Select all
StrLenA(str) {
Return StrPut(str, "cp0") - 1
}
Users browsing this forum: No registered users and 13 guests