Home > .NET Development > How to display non-latin characters in ASP Classic

How to display non-latin characters in ASP Classic

I was ask to create COM+ that will return data from DB2 to Classic ASP that has multi-language support.

At first, it was really a headache on how I can accomplish this project. I’ve try to just passed the data comming from DB2 directly to ASP but it was totally garbage.

Well the solution is seems simple, I connect to DB2 server passed the query and then convert the result to Ascii Codes, I set a delimiter for every row, every item, and every letters from COM+ and pass it to ASP then convert again to characters by using spit() , Chr & ChrW function to convert to character since the charset and code page is already declared.

C# Code for converting to ASCII – delimited by & per character:

public static string Chr(string str)
if (str.Length > 0)
StringBuilder retStr = new StringBuilder();
char[] arrychr = str.ToCharArray();
foreach (char chr in arrychr)
int asciicode = (int)chr;
retStr.Append("&" + asciicode.ToString());
return retStr.ToString();
return "";

Function in ASP to convert from ASCII to Characters:

Function ConvertToChar(byval str)
dim delrows, delitems, delcols
delrows = "___NLINE__"
delcols = "N$XITM_"
delitems = "&"
'return string
dim strConverted
dim arryRows, arryCols, arryItems
dim ctrrows, ctrcol, ctritems
'Ubound Var
dim UarryRows,UarryCols,UarryItems
strConverted = ""
dim ichr
'Get the Rows
arryRows = split(str,delrows)
UarryRows = Cint(Ubound(arryRows))
for ctrrows = 0 to UarryRows
'Get Columns
arryCols = split(arryRows(ctrrows),delcols)
UarryCols = Cint(ubound(arryCols))
for ctrCol = 0 to UarryCols
'Get Items
arryItems = split(arryCols(ctrCol),delitems)
UarryItems = Cint(UBound(arryItems))
for ctrItems = 0 to UarryItems
'checks if Item is ASCII Code
if len(arryItems(ctrItems)) > 1 then
ichr = cLng(arryItems(ctrItems))
select case ichr
case 219,254,221: 'this characters are whitespace
case else:
if ichr > 254 then
strConverted = strConverted & Chrw(ichr)
strConverted = strConverted & Chr(ichr)
end if
end select
strConverted = strConverted & arryItems(ctrItems)
end if
'Adds NextItem Attrib
if (ctrCol UarryCols) then strConverted = strConverted & delcols
'Adds NextLine Attrib
if (ctrrows UarryRows) then strConverted = strConverted & delrows
ConvertToChar = strConverted
End Function

I get data from DB2 using Dataset and I loop each rows in the dataset to construct a string, since string datatype is compatible with Classic ASP, My delimiter per row is “___NLINE__” and per column is
“N$XITM_”. Also in order to connect to DB2, I used Ritmo Driver for iSeries, its a third-party driver that supports .NET.

Categories: .NET Development Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: