Re: Wrong text formatting saved from stream

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



AllisonJ wrote:

I'm trying to download a text file through the download dialog box using Ado
stream:


set adoStream = Server.CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.CharSet = "x-ansi"
adoStream.Type = 2 ' adTypeText
adoStream.WriteText( file_body )
adoStream.Position = 0
adoStream.Type = 1 'adTypeBinary

Response.Clear
Response.AddHeader "Content-Length", len(file_body)
Response.AddHeader "Content-Transfer-Encoding", "binary"
Response.AddHeader "Content-Disposition", "attachment; filename="&
file_name &"; "
Response.ContentType = "application/unknown"
Response.BinaryWrite( adoStream.Read() )
adoStream.Close
Response.End

This is the look of the original string, with carriage returns and line
feeds properly displayed



But when I open the downloaded file, it looks like this:




How can I recover the original formating of the file_body string in the
saved file
Also I tried to use the ReadText method, but it puts a space between each
character (???)

How can I solve this
Any clues highly appreciated
--------------------
You probably want to use a different value for CharSet. Try "Unicode" (the
default). Other possibilities are "iso-8859-1" and "Windows-1252". See this
link:

http://msdn2.microsoft.com/en-us/library/ms681424.aspx

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages