473,473 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Writing to valid ANSI text file (UTF8 issue?)

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
Sep 1 '05 #1
2 12062
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" <ma**@SPAMMENOTyeardley.demon.co.uk> wrote in message
news:ux**************@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

Sep 1 '05 #2
"Aaron Bertrand [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in
message news:eI**************@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
Sep 1 '05 #3

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

Similar topics

10
by: Neil Trigger | last post by:
Is there a way of creating a seperate text file on a server every time a form is sent? -- ¿ Trigger ? http://www.magic2k.com/ http://www.oddmap.co.uk
3
by: Ian Davies | last post by:
I have the following code which displays some some formatted text in my browser. The problem is I need to create a text file and write the records from this array into it. Does anyone know how to...
3
by: Jennifer | last post by:
On an ASP page I've got some code that is supposed to "export" data in a grid to an Excel file. What I'm doing is writing all the data to a text file, separating the fields by commas. Then I'll...
2
by: Nikolay Petrov | last post by:
How to read ANSI text. The sream reader reads only UTF-8
8
by: gordon | last post by:
Hi I am learning vb.net and am trying to write information to a text file or to append to that file if it already exists. I am using the following code to write to the file, however the text...
2
by: Cleako | last post by:
I am writing a program that formats the data and prints it to a text file. I know that a text file wont hold the form feed and recognize it but what is an ideal way to get a new page? Would it...
3
by: mainul | last post by:
Hi guys i can write text file and also can read it. below are the codes. <?PHP //write to a file $body_content="This is my content"; // Store some text to enter inside the file...
1
by: gmulholland | last post by:
HI, I am wondering if anyone knows how to specify what character set will be used when creating and then writing to a text file. This app says "create myfile.txt, then does a print to file method...
4
by: pbj2009 | last post by:
Hello all: I'm pretty stumped on this one. I'm not looking for Code, I'm just trying to figure out the best way to start this since I am new to reading and writing from files. I can't figure out...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
1
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: 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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.