473,464 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ASCII HTML written in UNICODE by ASP?

Hi,

I've been working on a project that will help me save some time. It
basically reads a URL and saves it to disk as an html file. In other
words, I just wanted to make the automated version of "Save As -> HTML
Only" command on Internet Explorer.

I use XMLHTTP component for this task. I created 3 functions:
readURL: Reads the given URL using Microsoft.XMLHTTP component and
returns the content.
createHTMLFile: Creates the HTML file using the given body string. It
was giving me error before I use the getFileFormat.
getFileFormat: I copied and pasted from a newsgroup, supposed to find
the content format (ASCII or UNICODE)

Here is my catastrophe: If I don't use getFileFormat, XMLHTTP output
cannot be saved. If I use the getFileFormat, it saves in UNICODE and I
cannot use the file in other text processing tools, such as Handy File
Find & Replace. I also doublechecked the web page I'm saving, it's
using ISO-8859-1 in HTTP headers.

Do you have any suggestions?

Thanks in advance,
~D

function readUrl(url)
Dim xml, search_result, output
' Set xml = Server.CreateObject("Msxml2.XMLHTTP.4.0")
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", url, False
xml.Send
readUrl = xml.responseText
Set xml = Nothing
end function

sub createHTMLFile(file,content)
dim fso, newFile
Set fso = CreateObject("Scripting.FileSystemObject")
'on error resume next
Set newFile = fso.CreateTextFile(file,true,getFileFormat(content ))
'if err > 0 then response.write file
'on error goto 0
newFile.write (content)
newFile.close
set newFile = nothing
set fso = nothing
end sub

function getFileFormat(ByRef vTxt)
const UNICODE = -1, ASCII = 0
a2 = Asc(Mid(vTxt,2,1))
w3 = AscB(MidB(vTxt,3,1))
w2 = AscB(MidB(vTxt,2,1))
getFileFormat = ASCII
if a2<>w2 AND a2=w3 Then getFileFormat = UNICODE
end function
Jul 19 '05 #1
0 2592

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Randell D. | last post by:
Folks, I have two related questions: 1. I have seen unicode being mentioned in my javascript pocket book - is this the same as ascii codes? I think not though I'm not sure and I can't find...
4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
19
by: Frank | last post by:
Hi, what IO class or encoding writes a + umlaut (ä) as 1 character to a file? Looks like streamwriters don't, should I use binarywriter? Thanx in advance Frank
18
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found...
24
by: ChaosKCW | last post by:
Hi I am reading from an oracle database using cx_Oracle. I am writing to a SQLite database using apsw. The oracle database is returning utf-8 characters for euopean item names, ie special...
2
by: joakim.hove | last post by:
Hello, I am having great problems writing norwegian characters æøå to file from a python application. My (simplified) scenario is as follows: 1. I have a web form where the user can enter his...
19
by: Thomas W | last post by:
I'm getting really annoyed with python in regards to unicode/ascii-encoding problems. The string below is the encoding of the norwegian word "fødselsdag". I stored the string as "fødselsdag"...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
5
by: tushar.saxena | last post by:
This post is a follow up to the post at : http://groups.google.com/group/comp.lang.c++/browse_thread/thread/83af6123fa945e8b?hl=ug#9eaa6fab5622424e as my original question was answered there, but I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.