Hi, I've a problem with code that should produce a Windows(ANSI) encoded
text file but doesn't. Server is IIS 5 on Win 2k, with ASP ver?

My ASP uses data from an upstream HTML form on a UTF-8 encoded page. The
latter is output by a server-side system and I can't alter that source
format.

Here's some of the ASP code (may wrap):

' Following vars are longer strings but of this type - just more Request
object vlaues added
strLabels = "Filename" & vbTab "EXTENDED_DESCRIPTION"
strValues = Request.Form("Filename") & vbTab &
Request.Form("EXTENDED_DESCRIPTION")

On Error Resume Next
' set up the FSO
Set fso = CreateObject("Scripting.FileSystemObject")
' Create the lock file ('ture' arg allows file overwrite if already
exists)
Set objMyFile = fso.CreateTextFile(strDataFile, True)
If Err.Number = 0 Then
' Successfuly created file, let's write to it
objMyFile.WriteLine(strLabels)
objMyFile.WriteLine(strValues)
' close - we're done
objMyFile.Close

This code worked with the previous version of the server-side system but
since it was upgraded now the next part after the ASP form-to-file
process breaks as expects a Windows(ANSI) TXT file. When I do a text
import of my current ASP created files it reports "MS_DOS(PC-8)". I
assume the move to UTF-* encoded pages upstream is the issue.

I assume the ASP is getting UTF-8 values from the Response object. How
can I parse these to ANSI encoding to get a valid Windows(ANSI) Text
file?

Many thanks.

Mark

Re: Writing to valid ANSI text file (UTF8 issue?) by Aaron

Aaron
Thu Sep 01 08:50:24 CDT 2005

Take a look at the Unicode parameter of CreateTextFile and OpenTextFile (the
text file is probably being created as Unicode, but you can override this by
setting the Unicode property to false).




"Mark Anderson" <mark@SPAMMENOTyeardley.demon.co.uk> wrote in message
news:uxoWrKurFHA.2076@TK2MSFTNGP14.phx.gbl...
> Hi, I've a problem with code that should produce a Windows(ANSI) encoded
> text file but doesn't. Server is IIS 5 on Win 2k, with ASP ver?
>
> My ASP uses data from an upstream HTML form on a UTF-8 encoded page. The
> latter is output by a server-side system and I can't alter that source
> format.
>
> Here's some of the ASP code (may wrap):
>
> ' Following vars are longer strings but of this type - just more Request
> object vlaues added
> strLabels = "Filename" & vbTab "EXTENDED_DESCRIPTION"
> strValues = Request.Form("Filename") & vbTab &
> Request.Form("EXTENDED_DESCRIPTION")
>
> On Error Resume Next
> ' set up the FSO
> Set fso = CreateObject("Scripting.FileSystemObject")
> ' Create the lock file ('ture' arg allows file overwrite if already
> exists)
> Set objMyFile = fso.CreateTextFile(strDataFile, True)
> If Err.Number = 0 Then
> ' Successfuly created file, let's write to it
> objMyFile.WriteLine(strLabels)
> objMyFile.WriteLine(strValues)
> ' close - we're done
> objMyFile.Close
>
> This code worked with the previous version of the server-side system but
> since it was upgraded now the next part after the ASP form-to-file process
> breaks as expects a Windows(ANSI) TXT file. When I do a text import of my
> current ASP created files it reports "MS_DOS(PC-8)". I assume the move to
> UTF-* encoded pages upstream is the issue.
>
> I assume the ASP is getting UTF-8 values from the Response object. How can
> I parse these to ANSI encoding to get a valid Windows(ANSI) Text file?
>
> Many thanks.
>
> Mark
>
>



Re: Writing to valid ANSI text file (UTF8 issue?) by Mark

Mark
Thu Sep 01 14:00:02 CDT 2005

"Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in
message news:eIeW2vvrFHA.3060@TK2MSFTNGP09.phx.gbl...
> Take a look at the Unicode parameter of CreateTextFile and
> OpenTextFile (the text file is probably being created as Unicode, but
> you can override this by setting the Unicode property to false).
>

Thanks.

Mark