vb6Private 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
邮件已经发了.其中包含了一个可以通过数据库进行简繁转换的. CREATE TABLE [dbo].[ietrandata]( [uid] [numeric](18, 0) IDENTITY(1,1) NOT NULL, [cht_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_cht_i] DEFAULT ((0)), [chs_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_chs_i] DEFAULT ((0)), [cht_c] [varchar](2) COLLATE Chinese_Taiwan_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_cht_c] DEFAULT (''), [chs_c] [varchar](2) COLLATE Chinese_PRC_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_chs_c] DEFAULT (''), [chss_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_chss_i] DEFAULT ((0)), [chss_c] [varchar](2) COLLATE Chinese_PRC_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_chss_c] DEFAULT (''), [chst_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_chst_i] DEFAULT ((0)), [chst_c] [varchar](2) COLLATE Chinese_PRC_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_chst_c] DEFAULT (''), [u_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_u_i] DEFAULT ((0)), [u_c] [nvarchar](1) NOT NULL CONSTRAINT [DF_ietrandata_u_c] DEFAULT ('') ) ON [PRIMARY] _I:Binary值 _C:varchar值cht:繁体 chs:简体u:Unicodechss:GBK简体 chst:GBK繁体
同意用 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 LongPrivate Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long但是在98下,这2个不行的,需要自己按字对照,一一进行转换。
To fangmanhua8888,简体环境下,Win2000以上操作系统都支持.由于简体当中有GBK库,同时包含了简体字和繁体字,所以几乎所有BIG5码都在其中有对应,但是反过来,BIG5当中仅只有GBK的繁体字,那样对于很大一部分简体字在做转换的时候中就已经被无效符号填充了(一般是问号).
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
strSimplifiedChinese = "我是中国人!"
strTraditionalChinese = StrConv(strSimplifiedChinese, VbStrConv.TraditionalChinese) '简转繁 Console.Write(strTraditionalChinese)
strSimplifiedChinese = StrConv(strTraditionalChinese, VbStrConv.SimplifiedChinese) '繁转简
Console.Write(strSimplifiedChinese)
后面这.net的可以无视之。
ANSI版的,我有上传过一份资源,是一个DLL(http://download.csdn.net/source/752666).Unicode的,我只有码表,以前针对数据库,Word,Excel和Access有做过转换程序.
'我是數據表中的繁體字段數據,類型為nvarchar(255),用VB6.0獲取後,再轉為簡體的字段數據,類型也是'nvarchar(255)
'可不可以直接在數據中轉化呢?
CREATE TABLE [dbo].[ietrandata](
[uid] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[cht_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_cht_i] DEFAULT ((0)),
[chs_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_chs_i] DEFAULT ((0)),
[cht_c] [varchar](2) COLLATE Chinese_Taiwan_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_cht_c] DEFAULT (''),
[chs_c] [varchar](2) COLLATE Chinese_PRC_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_chs_c] DEFAULT (''),
[chss_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_chss_i] DEFAULT ((0)),
[chss_c] [varchar](2) COLLATE Chinese_PRC_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_chss_c] DEFAULT (''),
[chst_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_chst_i] DEFAULT ((0)),
[chst_c] [varchar](2) COLLATE Chinese_PRC_Stroke_BIN NOT NULL CONSTRAINT [DF_ietrandata_chst_c] DEFAULT (''),
[u_i] [varbinary](2) NOT NULL CONSTRAINT [DF_ietrandata_u_i] DEFAULT ((0)),
[u_c] [nvarchar](1) NOT NULL CONSTRAINT [DF_ietrandata_u_c] DEFAULT ('')
) ON [PRIMARY]
_I:Binary值
_C:varchar值cht:繁体
chs:简体u:Unicodechss:GBK简体
chst:GBK繁体
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 LongPrivate Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As String) As Long但是在98下,这2个不行的,需要自己按字对照,一一进行转换。