AllExperts > Experts 
Search      

Active Server Pages Programming (ASP)

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Active Server Pages Programming (ASP) Answers
Question Library

Ask a question about Active Server Pages Programming (ASP)
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Jeff Allen
Expertise
I can answer basic to intermediate questions related to Classic ASP.I can answer Intermediate to Advanced questions CSS& HTML, and basic questions about JavaScript and Ajax. I can also answer questions related to web page accessibility under US Section 508.

Experience
I have 8 years experience with HTML. I have been developing in ASP, VBScript and CSS for two years each. I also currently work as web developer.

Organizations
IWA-HWG

Education/Credentials
I have a BA in English with minors in Web Design and Scientific and Technical Writing

 
   

You are here:  Experts > Computing/Technology > Business Software > Active Server Pages Programming (ASP) > dbcs to unicode

Topic: Active Server Pages Programming (ASP)



Expert: Jeff Allen
Date: 9/25/2006
Subject: dbcs to unicode

Question
Hi Expert Jeff,

I got a very difficult question!

Given the code of a character in format "&#xxx;&#xxx;" where "xxx" is some 3 digit decimal number, convert the code in format "&#xxxxx;" for the same character where "xxxxx" is a 5 digit decimal number.

Do you know how to do this within an ASP page?

Thanks a lot in advance.

Weel


Answer
There are a number of ways to do this really... but one of the easiest is with a function... THis of course depends onthe fact that you know the value of a character in &#xxx and its equal in the xxxxx digit format..

So to do it with a function in ASP let's write a function called replaceChars(char,num).

public function replaceChars(char,num)
dim error : error = 0
select case num
case 0
'This portion replaces the ASCII character (') with a 5 digit equivalent
char = Trim(Replace(char, " ", " "))'One of these lines per character to be replaced
char = Trim(Replace(char, " ", " "))
replaceChars = char
case 1
'This would take the 5 digit equivalent and replace it witht he correct ASCII code equivalent
char = Trim(Replace(char, " ", " "))'One of these lines per character to be replaced
char = Trim(Replace(char, " ", " "))
replaceChars = char
case else
    error = 1
end select
if error <> 0 then
    response.write "replaceChars(char,num) error / check your syntax"
end if
end function

Now you'll need to fill in all the &#xxx characters one per line in both case 0 and case 1 as well as matching them with their 5 digit equivalents in each line in both cases.

So in your ASP you would call this like:
<%
replaceChars("&#xxx","xxxxx",0)
%>
to replace the ASCII witht he five digit and like this:
<%
repaceChars("xxxxx","&#xxx".1)
%>
to convert it back so that you are replacing the 5 digit with its ACII equal

Here's a glimpse at the standard ASCII Set for HTML 4.01
http://www.uwsp.edu/conted/test/standard_ascii_set.htm

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.