Using ASP to realize simple simplified conversion

Source: Internet
Author: User

Using ASP to realize simple simplified conversion

Internationalization seems to be a very popular slogan, a website does not have the English version at least to get a traditional version, after all, are Chinese characters, translation will not be so troublesome: P

The general simplified conversion is to use a dictionary, through the GB of the internal code to calculate the position of the BIG5 character in the dictionary, read the display, with the FSO should be able to achieve. The method introduced here is more simple, with Dictionary object, is the dictionary, hehe, DICGB2BIG5 (GB) is the corresponding BIG5. It is easier to read the characters by location than in the calculation code:)

To reduce overhead, place the dictionary in application, which is to create two application dictionary objects in the Global.asa

<object id=objgb2big5 progid= "scripting.dictionrary" runat= "Server" scope= "Application" >
</OBJECT>
<object id=objbig52gb progid= "scripting.dictionrary" runat= "Server" scope= "Application" >
</OBJECT>

Add items to a dictionary in Application_OnStart

......
Objgb2big5.add "Ah", "pendulum"
Objgb2big5.add "Ah", ""
Objgb2big5.add "Aye", "bottle"
......

......
Objbig52gb.add "Pendulum", "Ah"
Objbig52gb.add "", "Ah"
Objbig52gb.add "Bottle", "Aye"
......

A lot of dictionaries, not all of them.

Do a dictionary, use the time as long as a check on the line:)

function Gb2big5 (str)
Dim i, L, K, T, RTN
L = Len (str)
Rtn= ""
For I=1 to L
K = Mid (str, I, 1)
If AscW (k) >=0 and AscW (k) <128 Then
t = k
Else
If Objgb2big5.exists (k) Then
T = Objgb2big5.item (k)
Else
t = ""
End If
End If
RTN = RTN & T
Next
Gb2big5 = Rtn
End Function

function BIG52GB (str)
Dim i, L, K, T, RTN
L = Len (str)
Rtn= ""
For I=1 to L
K = Mid (str, I, 1)
If AscW (k) >=0 and AscW (k) <128 Then
t = k
Else
If Objbig52gb.exists (k) Then
T = Objbig52gb.item (k)
Else
t = ""
End If
End If
RTN = RTN & T
Next
BIG52GB = Rtn
End Function

Let's test it out.

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.