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
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 "xx;xx;" where "xxx" is some 3 digit decimal number, convert the code in format "xxxx;" 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 xx 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 xx 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("xx","xxxxx",0)
%>
to replace the ASCII witht he five digit and like this:
<%
repaceChars("xxxxx","xx".1)
%>
to convert it back so that you are replacing the 5 digit with its ACII equal