21-1 ?件????網?????簡???

b ASP Aڭ̥iHϥηLn@~tΤت WinHttp.WinHttpRequest.5.1 ӧLTAiBzAAiܳBz᪺GCҦpAUCdҨϥ WinHttp.WinHttpRequest.5.1 ӧ Google ]http://www.google.com.tw^AMܦlXApUG

Example]getWebPage/showSource01.asp^G

WzdҪlXpUG

lɡ]getWebPage/showSource01.asp^G]ǦϰUYi^
<%@language=JScript%>
<% title=" utf-8 ܭlX" %>
<!--#include file="../head.inc"-->
<hr>
<%
url="http://www.google.com.tw";		// The URL to download
httpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
httpReq.Open("GET", url, false);
httpReq.Send();			// Download the file
content = httpReq.ResponseText;
%>

<fieldset>
<legend><a target=_blank href="<%=url%>"><%=url%></a> lX</legend>
<xmp><%=content%></xmp>
</fieldset>

<hr>
<!--#include file="../foot.inc"-->

bWzdҤAѩ Google OH utf-8 sXAWinHttp.WinHttpRequest.5.1 n䴩AҥH@SDCOpGAn쪺OH big5 sXA^ǪegѽsXL{A~e{TGA_hN|X{ýXCbUoӽdҤAڭ̧@ӤjXAèϥΥt~@Ӥ adodb.stream ӶisXG

Example]getWebPage/showSource03.asp^G

WzdҪlXpUG

lɡ]getWebPage/showSource03.asp^G]ǦϰUYi^
<%@language=JScript%>
<% title=" big5 ܭlX" %>
<!--#include file="../head.inc"-->
<hr>
<%
url = "http://neural.cs.nthu.edu.tw/jang/books/html/example/image02.htm";
// Step 1: ϥ WinHttp.WinHttpRequest ӧ
WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpReq.Open("GET", url, false);
WinHttpReq.Send();			// Download the file
content = WinHttpReq.ResponseBody;	// ^ binary 
// Step 2: ϥ adodb.stream ӶisX
oStream = new ActiveXObject("adodb.stream");   
oStream.Type=1;			// HGi覡ާ@
oStream.Mode=3;			// iPɶiŪg
oStream.Open();			// }Ҫ
oStream.Write(content);		// N content gJ
oStream.Position=0;		// qY}l
oStream.Type=2;			// HrҦާ@
oStream.Charset="Big5";		// ]wsX覡
result= oStream.ReadText();	// N󤺪rŪX
%>

<fieldset>
<legend><a target=_blank href="<%=url%>"><%=url%></a> lX</legend>
<xmp><%=result%></xmp>
</fieldset>

<hr>
<!--#include file="../foot.inc"-->

bWzdҤAڭ̨ϥΤF adodb.stream A󴣨ѤFBz binary ascii ƪUؤkA\ܱjjCdҭlXѡAbAحzCYnD󪺨LΪkAŪ̥iHb Google J adodb.streamANiHC

ڭ̤]iHXAߨϥΥt@Ӥ Hokoy.WordKit ӱNeন²rAAe{AdҦpUG

Example]getWebPage/big5toGb01.asp^G

]YWzdҵLkTe{AhܹA|w Hokoy.WordKit C^dҪlXpUG

lɡ]getWebPage/big5toGb01.asp^G]ǦϰUYi^
<%@language=jscript%>
<%title="cåH²e{"%>
<%
url = "http://neural.cs.nthu.edu.tw/jang/books/html/example/image02.htm";
// Step 1: ϥ WinHttp.WinHttpRequest ӧ
WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
WinHttpReq.Open("GET", url, false);
WinHttpReq.Send();			// Download the file
content = WinHttpReq.ResponseBody;
// Step 2: ϥ adob.stream ӶiƽsX
oStream = new ActiveXObject("adodb.stream");   
oStream.Type=1;
oStream.Mode=3;
oStream.Open();
oStream.Write(content);
oStream.Position=0;   
oStream.Type=2;
oStream.Charset="Big5"   
result= oStream.ReadText();
// Step 3: ϥ Hokoy.WordKit ഫ²
wordToolObj = new ActiveXObject("Hokoy.WordKit");
gbContent=wordToolObj.Big5toGB(result);
// Step 4: ܺsXñNƧe{
Response.Charset="gb2312";
Response.Write(gbContent);
%>

bWzdҪlXAiHݥXڭ̰kpUG

  1. ϥ WinHttp.WinHttpRequest.5.1 ӧ@ӺeC
  2. ϥ adodb.stream ӱNҧ쪺 binary ର big5 sXC
  3. ϥ Hokoy.WordKit ӱNcন²C
  4. ϥ Response.Charset ӱNsXאּ "gb2312" ²sXAñNƼgJC

ѩڭ̥Neন²A|bP|e{A]Ҧ۹|s|oͿ~CѨMDAڭ̪{XP_۹|ssbAñN令|AAe{sAڭ̱No@@@DC

~AWzdҤ Hokoy.WordKit O@ӫܦnΪAFiHNcন²~A٥iHiUؤXCiѡuѭJMHvҴѡAiѤUC}UG

http://reg.softking.com.tw/freeware/index.asp?fid1=3&fid2=260&fid3=22195
U Hokoy.WordKit.dll AеUG
  1. N Hokoy.WordKit.dll c:\windows\system32 ؿUC
  2. } DOS AiJ c:\windows\system32 ؿUAb DOS Juregsvr32 Hokoy.WordKit.dllvAuTwvYwˡC

Hint
ثe Hokoy.WordKit ȯΦb 32-bit Windows xC

Hokoy.WordKit \iHCpUG

禡WJsXOXsXO
GBtoBig5GBBig5
BIG5toGBBig5GB
GBtoUnicodeGBUnicode
Big5toUnicodeBig5Unicode
UnicodetoGBUnicodeGB
UnicodetoBig5UnicodeBig5
SCtoTCUnicode²rUnicodecr
TCtoSCUnicodecrUnicode²r

t@ӱqAݨӶiuc²vѨMסAhiH׶}۹|קAy{pUG

  1. bݭn²骺ɤJuc²v{Xɮס]pUz big5toGb.inc ɮס^C
  2. un}aulanguage=gbvѼơAWz{XN|Neର²C
ڭ̥Ӭݤ@ӽdҡA]lcpUG lXpUG

lɡ]getWebPage/fullUrl01.asp^G]ǦϰUYi^
<%@language=JScript%>
<% title="c²" %>
<!--#include file="../head.inc"-->
<hr>

oO@ʺ}GI
<img align=top src="sbtree.gif">

<hr>
<!--#include file="../foot.inc"-->

Example]getWebPage/fullUrl01.asp^G

YnN令²AuݾɤJ big5toGb.inc æb}[J language=gb ﶵAdҦpUG

Example]getWebPage/fullUrl02.asp?language=gb^G

]YWzdҵLkTe{AhܹA|w Hokoy.WordKit C^dҪlXpUG

lɡ]getWebPage/fullUrl02.asp^G]ǦϰUYi^
<%@language=JScript%>
<!--#include file="big5toGb.inc"-->
<% title="c²" %>
<hr>

<!--#include file="../head.inc"-->
oO@ʺ}GI
<img align=top src="sbtree.gif">

<hr>
<!--#include file="../foot.inc"-->

bWzdҤAڭ̤wgb[Jc²骺{X big5toGb.incAɥunb}[Wu?language=gbvAɺeN|Qন²餤C~AѩèS|ഫDA]ϥά۹|ܾ𪺼vAഫèèSvTC

bWzdҤAҾɤJuc²v{Xɮ׬ big5toGB.incAepUG

lɡ]getWebPage/big5toGb.inc^G]ǦϰUYi^
<%
// o http |
function getFullUrl(){
	var domainName=Request.ServerVariables("SERVER_NAME");
	var absPath=Request.ServerVariables("url");
	var queryString=Request.ServerVariables("query_string")+"";

	if (queryString=="")
		url="http://" + domainName + absPath;
	else
		url="http://" + domainName + absPath + "?" + queryString;
	return(url);
}

language=Request("language")+"";
//Response.Write("<script>alert('"+language+"')</script>");
if (language=="gb"){
	url=getFullUrl();
	url=url.replace(/language=gb&/g, "");	// R language=gb&
	url=url.replace(/language=gb/g, "");	// R language=gb
	// Step 1: ϥ WinHttp.WinHttpRequest ӧ
	WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
	WinHttpReq.Open("GET", url, false);
	WinHttpReq.Send();			// Download the file
	content = WinHttpReq.ResponseBody;
	// Step 2: ϥ adodb.stream ӶisX
	oStream = new ActiveXObject("adodb.stream");   
	oStream.Type=1;
	oStream.Mode=3;
	oStream.Open();
	oStream.Write(content);
	oStream.Position=0;   
	oStream.Type=2;
	oStream.Charset="Big5"   
	result= oStream.ReadText();   
	// Step 3: ϥ Hokoy.WordKit ഫ²
	wordToolObj = new ActiveXObject("Hokoy.WordKit");
	gbContent=wordToolObj.Big5toGB(result);
	// Step 4: ܺsXñNƧe{
	Response.Charset="gb2312";
	Response.Write(gbContent);
	Response.End();
}
%>

bWz{XAu@y{iHpUG

  1. Yoı language=gb ﶵAhRﶵAMeC
  2. Neন²Ay{Me@ӽdҬO@˪C

JScript {]pPΡGΩAݪ ASP