?
Solved

How to convert a UNICODE string to ansi in ASP?

Posted on 2009-05-02
3
Medium Priority
?
858 Views
Last Modified: 2012-05-06
We are reading a SQL Server 2000 database and writing its contents out to a text file via our ASP web page.

The problem is that because the fields are defined as ntext, the resulting file is written out as unicode (we're just using the Scripting.FileSystemObject to create a text file and it appears to automatically be saving it as a unicode file).

This is a problem because the 3rd party system we send the text file off to cannot process the unicode data.

We tried casting the SQL field to text (from its original unicode ntext type) but the resulting string was still unicode.

QUESTION: Is there a way in ASP to convert a UNICODE string to ANSI prior to writing it out to the file?

Thanks experts!
0
Comment
Question by:rascal
3 Comments
 
LVL 3

Accepted Solution

by:
prachwal earned 2000 total points
ID: 24287626
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 24287654
Since this is a duplicate question for:
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_24375225.html
Please request that it be deleted.
0
 
LVL 1

Author Comment

by:rascal
ID: 24287932
Actually the above solution didn't actually fix the problem (which I hadn't fully realized)
I had to explicitly open the text file in ANSI mode in order to get the resulting file to be ANSI. Just relying on the default open mode for the file still resulted in Unicode.
Here is the code I used:


 dim f
 const ForReading = 1
 const ForWriting = 2
 const ForAppending = 8
    const TristateUseDefault = -2
 const TristateTrue = -1
 const TristateFalse = 0
    objFSO.CreateTextFile sOutputFilename, 2, true   ' 2 = for writing, true = create
 set f = objFSO.GetFile(sOutputFilename)
    set objFile = f.OpenAsTextStream(ForWriting, TristateFalse)
 
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question