Library tutorials & articles

ADO and Unicode

database_result.asp

  • The session.codepage must be set to 65501. This session codepage is support only in Internet Information Server 5.0 (IIS 5.0).
  • Retrieval of unicode values must be done through a stored procedure, get_unicode.
  • Optional: You can specify a font family. The font family must support Unicode code points. Here's one font that will work: style="font-family: arial unicode ms"

<%
   Dim cnn, rstUnicode,strSQL,cmd
   Dim sCriteria
   Dim sUnicode_Number
   Dim sCode_Point
   Dim sUnicode_Code_Points
   Dim sOutput

   session.CodePage=65001
   Response.Buffer = True


   sUnicode_Code_Points=""
   Set cnn = Server.CreateObject("ADODB.Connection")
   cnn.Open "your_dsn", "user_name", "password"

   sCode_Point=Request("code_point")
   sUnicode_Number=Request("unicode_number")
   
   set rstUnicode=nothing

   if len(sUnicode_Number)>0 or len(sCode_Point)>0 then

       set cmd=Server.CreateObject("ADODB.Command")
       cmd.ActiveConnection=cnn
       cmd.CommandText="get_unicode"
       cmd.CommandType=adCmdStoredProc
       'Unicode Value
       cmd.Parameters.append cmd.CreateParameter("@p_unicode_number",adVarChar,adParamInput,50,sUnicode_Number)
       'Unicode Code Point
       cmd.Parameters.append cmd.CreateParameter("@p_code_point",adVarWChar,adParamInput,200,sCode_Point)
       cmd.Parameters.append cmd.CreateParameter("@p_output_code_point",adVarWChar,adParamOutput,200,"")

       cmd.Execute

       sUnicode_Code_Points=""&cmd.Parameters("@p_output_code_point").value            
       if sUnicode_Code_Points="" then
           Response.Write "No Records Found"
           Response.end
       end if
   else
       Response.Redirect("unicode.html")
   end if
   
%>

   <HTML>
   <HEAD>
       <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
       <TITLE>
       Unicode Submission Test - Database
       <%=sUnicode_Code_Points%>
       </TITLE>
   </HEAD>

   <BODY>

   <TABLE BORDER=1 WIDTH=700>
   <TR BGCOLOR="lemonchiffon"><TH>Code</TH><TH>Display</TH><TH>Notes</TH></TR>
   <TR>
       <TD><SMALL><%=Len(sUnicode_Code_Points)%></SMALL></TD>
       <TD>You submitted <B><%=Len(sUnicode_Code_Points)%></B> characters.</TD>
       <TD>Length of code point submitted</TD>
   </TR>
   <%
       strSQL="select length(code_point) field_length from unicode_test where unicode='"&sUnicode_Number&"'"
       set rstUnicode= cnn.Execute(strSQL)
   %>
   <%
       if not rstUnicode.eof then
   %>
       <tr>
           
           <TD><SMALL><%=strSQL%></SMALL></TD>
           <TD><%=rstUnicode("field_length")%></TD>
           <TD>Unicode Code Point Length in Database</TD>

       </tr>
   <%
       end if
   %>
   <TR>
       <TD><SMALL><%=rstUnicode("code_point")%></SMALL></TD>
       <TD><%=sUnicode_Code_Points%></TD>
       <TD>Unicode Code Points - Rendered by the Browser</TD>
   </TR>
   </TABLE>

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of ADO and Unicode.

Leave a comment

Sign in or Join us (it's free).

David Nishimoto NishiSoft provides Part I of the Information Technology Project collaboration. Sign up and list your IT project tasks, assign task too friends, and get percent complete task. Part will include a wo...

Related podcasts

  • Java Posse #213 - Newscast for Oct 23rd 2008

    Newscast for Oct 23rd 2008 Fully formatted shownotes can always be found at http://javaposse.com The Android project has been released as open source, beating the rumored launch date for the source code by several months http://source.android.com/ And, Gizmodo and ZDNet both offer in-depth ...

Want to stay in touch with what's going on? Follow us on twitter!