Writing to valid ANSI text file (UTF8 issue?)

M

Mark Anderson

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
 
A

Aaron Bertrand [SQL Server MVP]

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).
 
M

Mark Anderson

Aaron Bertrand said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top