473,320 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2591

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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.