Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

Add Google Search to Windows-1256 Arabic ASP Page

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

ASP example code showing how to use the Google Search API and convert the utf-8 XML response to Windows-1256 for display on a Arabic ASP page.

<%@ LANGUAGE="VBSCRIPT" %>
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=Windows-1256">
<title>Sample Arabic Google Search</title>
</head>

<body bgcolor="#FFFFFF">

<% 

Dim GoogleUrl,GoogleKey,SoapText,ObjXml,UnicodeResponse,CXml

' Get a key from Google...
GoogleKey = "00000000000000000000000000000000"

' Create a SOAP message for a Google Search Request
' The language is set to Arabic
SoapText = "<?xml version='1.0' encoding='UTF-8'?>" & _
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"" " & _
"xmlns:xsi=""http://www.w3.org/1999/XMLSchema-instance"" " & _
"xmlns:xsd=""http://www.w3.org/1999/XMLSchema"">" & _
"  <SOAP-ENV:Body>" & _
"    <ns1:doGoogleSearch xmlns:ns1=""urn:GoogleSearch"" " & _
"         SOAP-ENV:encodingStyle=""http://schemas.xmlsoap.org/soap/encoding/"">" & _
"      <key xsi:type=""xsd:string"">"&GoogleKey&"</key>" & _
"      <q xsi:type=""xsd:string"">Arabic newspaper</q>" & _
"      <start xsi:type=""xsd:int"">0</start>" & _
"      <maxResults xsi:type=""xsd:int"">10</maxResults>" & _
"      <filter xsi:type=""xsd:boolean"">true</filter>" & _
"      <restrict xsi:type=""xsd:string""></restrict>" & _
"      <safeSearch xsi:type=""xsd:boolean"">false</safeSearch>" & _
"      <lr xsi:type=""xsd:string"">lang_ar</lr>" & _
"      <ie xsi:type=""xsd:string"">latin1</ie>" & _
"      <oe xsi:type=""xsd:string"">latin1</oe>" & _
"    </ns1:doGoogleSearch>" & _
"  </SOAP-ENV:Body>" & _
"</SOAP-ENV:Envelope>"

GoogleUrl = "http://api.google.com/search/beta2"  

' Make the SOAP Google API Call
Set ObjXml = CreateObject("Microsoft.XMLHTTP") 
ObjXml.open "POST",GoogleUrl,"False" 
ObjXml.setRequestHeader "Man", "POST"+" "+GoogleUrl+" HTTP/1.1"  
ObjXml.setRequestHeader "MessageType", "CALL"  
ObjXml.setRequestHeader "Content-Type", "text/xml"  
ObjXml.send SoapText  

' Get the Google Search Response
' Google requests and responses are always utf-8.
' However, when the Microsoft.XMLHTTP object returns the response
' text, it is already converted to a Unicode string.
UnicodeResponse = objXML.responseText 
Set ObjXml = Nothing 

' Create a Chilkat ASP XML object for easy parsing.
' ASP XML is a free ASP component from Chilkat Software.
set CXml = Server.CreateObject("Chilkat_9_5_0.Xml")
CXml.LoadXml UnicodeResponse

' This page requires Windows-1256
' Create a Chilkat Charset Conversion component for conversion from Unicode
' The Chilkat Charset component is not a free component, and can
' be licenced from Chilkat Software, Inc.
set cc = Server.CreateObject("Chilkat_9_5_0.Charset2")

' Any value passed to UnlockComponent begins the 30-day trial.
cc.UnlockComponent "30-day trial"
cc.ToCharset = "Windows-1256"

' Quickly navigate to the result elements.
set resultElements = CXml.SearchForTag(Nothing,"resultElements")
if not (resultElements is nothing) then

	' Find the first item
	set item = resultElements.SearchForTag(Nothing,"item")

	while not (item is nothing)
	
		Response.Write "Title: " 
		title = item.GetChildContent("title")
		if Len(title) > 0 then
			Response.BinaryWrite cc.ConvertFromUnicode(title)
		end if
		Response.Write "<br>"
		
		Response.Write "URL: " & item.GetChildContent("URL") & "<br>"

		Response.Write "Summary: " 
		summary = item.GetChildContent("summary")
		if Len(summary) > 0 then
			Response.BinaryWrite cc.ConvertFromUnicode(summary)
		end if
		Response.Write "<br><br>"
		
		set item = item.NextSibling()
	wend
else
	Response.Write CXml.GetXml()
end if

%>

</body>
</html>
 

© 2000-2025 Chilkat Software, Inc. All Rights Reserved.