| <%
Response.ContentType = "text/xml"
Response.Charset= "utf-8"
Response.ExpiresAbsolute=#May 31,2000 23:59:59#
' キャラクタセット変換用
Set Stream = Server.CreateObject( "ADODB.Stream" )
Set CAPIUtil = Server.CreateObject( "CAPICOM.Utilities" )
Set MyData = Server.CreateObject("Scripting.Dictionary")
' **********************************************************
' UTF-8 入力文字列の変換
' **********************************************************
Function ConvertQueryString()
Dim InData,nData,aData,I,strChar
Stream.Open
InData = Split( Request.QueryString, "&" )
For nData = 0 to Ubound( InData )
Stream.Position = 0
Stream.SetEOS
Stream.Charset = "utf-8"
Stream.Type = 1 ' バイナリ
aData = Split( InData(nData), "=" )
strChar =""
For I = 1 to Len( aData(1) )
strChar = Mid( aData(1), I, 1 )
if strChar = "%" then
I = I + 1
strChar = ChrB(CLng( "&H" & Mid( aData(1), I, 2 ) ))
I = I + 1
else
strChar = ChrB(Asc(strChar))
end if
ByteArray = CAPIUtil.BinaryStringToByteArray( strChar )
Stream.Write ByteArray
Next
Stream.Position = 0
Stream.Type = 2 ' テキスト
MyData( aData(0) ) = Stream.ReadText()
Next
Stream.Close
End Function
' ************************************************
' 内部コードを UTF-8 へ変換
' ************************************************
function ConvCharset( strValue )
Stream.Position = 0
Stream.SetEOS
Stream.Type = 2 ' テキスト
Stream.Charset = "utf-8"
Stream.WriteText strValue
Stream.Position = 0
Stream.Type = 1 ' バイナリ
Stream.Position = 3 ' BOM
ConvCharset = Stream.Read()
end function
Call ConvertQueryString()
Call DBConnectByEnv( Cn )
Query = "select * from T_学生マスタ_累積 where 入学年度 >= 2001"
if MyData("name") <> "" then
Query = Query & " and 学生氏名 like '%" _
& MyData("name") & "%'"
end if
strOrder = " order by コード"
Call DBGet( Cn, Rs, Query & strCond & strOrder, false )
%>
<!-- #include file = "../dbSS.inc" --><?xml version="1.0" encoding="UTF-8" ?>
<gakusei>
<query><% Response.BinaryWrite ConvCharset( Query ) %></query>
<%
nCount = 0
Do While not DBEof( Rs )
Response.Write "<row>" & vbCrLf
Response.Write "<id>" & Rs.Fields("コード").value & "</id>" & vbCrLf
Response.Write "<name>"
Response.BinaryWrite ConvCharset( Rs.Fields("学生氏名").value & "" )
Response.Write "</name>" & vbCrLf
Response.Write "<fname>"
Response.BinaryWrite ConvCharset( Rs.Fields("フリガナ").value & "" )
Response.Write "</fname>" & vbCrLf
Response.Write "</row>" & vbCrLf
nCount = nCount + 1
if nCount >= 50 then
Exit Do
end if
Rs.MoveNext
Loop
%></gakusei><% Call DBClose( Cn ) : Call DBClose( Rs ) : Stream.Close %>
| |