GB and BIG5 Internal code conversion COM original code

Source: Internet
Author: User
Tags exit empty resource
Convert this COM to use a VC resource file. is the dictionary.
We can go to 61.134.75.70/download/gb2big5.zip to download

The original code is as follows:

'//////////////////////////////////////////
' Chinese name: GB and BIG5 internal Code interchange control
' English name: Gb2big5
' Author: Blood
' Version: 1.0
' Production time: 2002.3.5
' All rights reserved Blood 2002-2003
'//////////////////////////////////////////

Option Explicit

' Define variables
Dim Big5data as Variant
Dim Gbdata as Variant

' Defines the custom type, which is used to handle the encoded high and low word problem
Type Chinesetypea
Lochar as Byte
Hichar as Byte
End Type

Private Big5type (&ha1 to &hff, &h40 to &HFE) as Chinesetypea ' corresponds to BIG5 font
Private Gbtype (&ha7 to &hff, &HA1 to &HFE) as Chinesetypea ' corresponds with GB font

'//////////////////
' Public function starts
'//////////////////

' BIG5 functions converted to GB

Function big5togb (strsource As String) as String
Dim I as Long, Y as Long
' defines an array for storing BIG5 and GB of internal code data
Dim bteBIG5 () as Byte
Dim BTEGB () as Byte

' If the input is empty, exit the function
If strsource = "" Then
BIG5TOGB = ""
Exit Function
End If

' Converts the type of the BIG5 array from Unicode encoding to system default code
BteBIG5 = StrConv (strsource, vbFromUnicode)
' Determines the subscript of the BIG5 array, which is used to iterate through the conversion of all BIG5 content to GB inner code
Y = UBound (bteBIG5)
ReDim BTEGB (0 to Y)
For I = 0 to Y
If I = Y Then
BTEGB (i) = BteBIG5 (i)
Exit for
End If
If bteBIG5 (i) < &AMP;HA1 Or BteBIG5 (i + 1) < &h40 Then
BTEGB (i) = BteBIG5 (i)
Else
BTEGB (i) = Big5type (BteBIG5 (i), bteBIG5 (i + 1)). Lochar
BTEGB (i + 1) = Big5type (BteBIG5 (i), bteBIG5 (i + 1)). Hichar
i = i + 1
End If
Next I
' Converts system default code to Unicode encoding
BIG5TOGB = StrConv (BTEGB, Vbunicode)
' Reinitialize the GB array to free up memory
Erase BTEGB
End Function

' GB conversion to BIG5 function

Function GBTOBIG5 (strsource As String) as String
Dim I as Long, Y as Long
' defines an array for storing BIG5 and GB of internal code data
Dim BTEGB () as Byte
Dim bteBIG5 () as Byte

' If the input is empty, exit the function
If strsource = "" Then
GBTOBIG5 = ""
Exit Function
End If

' Converts the type of a GB array from Unicode encoding to system default code
BTEGB = StrConv (strsource, vbFromUnicode)
' Determines the subscript of a GB array, which is used to loop all BIG5 content into GB
Y = UBound (BTEGB)
ReDim bteBIG5 (0 to Y)

For I = 0 to Y
If I = Y Then
BteBIG5 (i) = BTEGB (i)
Exit for
End If
If BTEGB (i) < &AMP;HA1 Or BTEGB (i + 1) < &AMP;HA1 Then
BteBIG5 (i) = BTEGB (i)
Else
If BTEGB (i) < &hb0 and BTEGB (i + 1) >= &ha1 Then
BteBIG5 (i) = Gbtype (BTEGB (i) + 6, BTEGB (i + 1)). Lochar
BteBIG5 (i + 1) = Gbtype (BTEGB (i) + 6, BTEGB (i + 1)). Hichar
Else
BteBIG5 (i) = Gbtype (BTEGB (i), BTEGB (i + 1)). Lochar
BteBIG5 (i + 1) = Gbtype (BTEGB (i), BTEGB (i + 1)). Hichar
End If
i = i + 1
End If
Next I
' Converts system default code to Unicode encoding
GBTOBIG5 = StrConv (bteBIG5, Vbunicode)
' Reinitialize the BIG5 array to free up memory
Erase bteBIG5
End Function

'//////////////////
' Public function ends
'//////////////////

' Class initialization
Private Sub Class_Initialize ()
Dim I as Long
Dim J as Long
Dim Ilen as Long

' Read the GB and BIG5 fonts from the resource file
Gbdata = LoadResData (102, "CUSTOM") '//Read GB font
Big5data = LoadResData ("CUSTOM") '/Read BIG5 font

For I = &AMP;HA1 to &hfe
For J = &h40 to &hfe
Big5type (I, J). Lochar = Big5data (Ilen)
Big5type (I, J). Hichar = Big5data (Ilen + 1)
Ilen = Ilen + 2
Next J
Next I

Ilen = 0

For I = &ha7 to &hfe
For J = &AMP;HA1 to &hfe
Gbtype (I, J). Lochar = Gbdata (Ilen)
Gbtype (I, J). Hichar = Gbdata (Ilen + 1)
Ilen = Ilen + 2
Next J
Next I
End Sub



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.