VBA 的全形半形轉換解決方案 中文系統有效

2021-06-06 05:21:20 字數 810 閱讀 4263

『全形轉半形

function tobanjiao(str as string) as string

dim cha as string

dim i1 as long

dim iasc as long

for i1 = 1 to len(str)

cha = mid(str, i1, 1)

iasc = clng(asc(cha)) + 23680

if iasc < 127 and iasc > 31 then

tobanjiao = tobanjiao & chr(iasc)

else

tobanjiao = tobanjiao & cha

end if

next

end function

』半形轉全形

function toquanjiao(str as string) as string

dim cha as string

dim i1 as long

dim iasc as long

for i1 = 1 to len(str)

cha = mid(str, i1, 1)

iasc = asc(cha)

if iasc < 127 and iasc > 31 then

toquanjiao = toquanjiao & chr(iasc - 23680)

else

toquanjiao = toquanjiao & cha

end if

next

end function

全形半形標點的轉換

full2half create function dbo full2half string nvarchar max returns nvarchar max as 全形 fullwidth 轉換為半形 halfwidth begin declare chr nchar 1 declare iin...

python中半形與全形互相轉換

半形與全形的轉換,如下 coding cp936 def strq2b ustring 全形轉半形 rstring for uchar in ustring inside code ord uchar if inside code 12288 全形空格直接轉換 inside code 32 elif...

半形 全形的轉換演算法

轉全形的函式 sbc case 任意字串 全形字串 全形空格為12288,半形空格為32 其他字元半形 33 126 與全形 65281 65374 的對應關係是 均相差65248 public string tosbc string input if c i 127 c i char c i 65...