VB中簡單實現繁體簡體互轉的辦法。

2021-04-02 11:11:04 字數 1032 閱讀 8190

先說明這個方法不是我原創的東西,只是我發現csdn上不少人在問,我也不止回答n次。有回答說用轉換表的,這不失乙個辦法,但是對於乙個簡單的程式還帶乙個龐大的表,畢竟很多人不樂意。其實api可以簡單地實現繁簡互轉。

事實上,這種辦法盡適合國標繁體與簡體的互相轉換。

private declare function lcmapstring lib "kernel32" alias "lcmapstringa" (byval locale as long, byval dwmapflags as long, byval lpsrcstr as string, byval cchsrc as long, byval lpdeststr as string, byval cchdest as long) as long

private declare function lstrlen lib "kernel32" alias "lstrlena" (byval lpstring as string) as long

'簡轉繁

public function jtof(byval str as string) as string

dim stlen as long

dim stf as string

stlen = lstrlen(str)

stf = space(stlen)

lcmapstring &h804, &h4000000, str, stlen, stf, stlen

jtof = stf

end function

'繁轉簡

public function ftoj(byval str as string) as string

dim stlen as long

dim stj as string

stlen = lstrlen(str)

stj = space(stlen)

lcmapstring &h804, &h2000000, str, stlen, stj, stlen

ftoj = stj

end function

Vb 實現簡體轉繁體

lcmapstring 映像字串 private declare function lcmapstring lib kernel32 alias lcmapstringa byval locale as long,byval dwmapflags as long,byval lpsrcstr as ...

VB6用API實現繁體簡體轉換

由於正好需要乙個繁體轉簡體的事情,弄這個函式將就用一下了。private declare function lcmapstring lib kernel32 alias lcmapstringa byval locale as long,byval dwmapflags as long,byval ...

VB6用API實現繁體簡體轉換

private declare function lcmapstring lib kernel32 alias lcmapstringa byval locale as long,byval dwmapflags as long,byval lpsrcstr as string,byval cchs...