Script(s)

what I learn is what u c

Creating UTF-8 files using ASP

with 11 comments

To create UTF-8 encoded files using ASP, using ADODB Stream object.

PS : Dont use FileSystemObject to create UTF-8 encoded files, as it wont work.

const adTypeBinary = 1
const adSaveCreateOverwrite = 2
const adModeReadWrite = 3

Set objStream = server.CreateObject(“ADODB.Stream”)
objStream.Open objStream.CharSet = “UTF-8”
objStream.WriteText(“your text goes here”)

objStream.SaveToFile server.mappath(“.”) & “/fname.txt” , adSaveCreateOverWrite
objStream.Close

Advertisements

Written by gchandra

August 19, 2004 at 1:31 pm

Posted in Web Coding

11 Responses

Subscribe to comments with RSS.

  1. This source codes is not working

    Âu Thiên Phúc

    May 20, 2008 at 4:26 pm

  2. This codes did not work

    Âu Thiên Phúc

    May 20, 2008 at 4:27 pm

  3. Did not work

    Âu Thiên Phúc

    May 20, 2008 at 4:27 pm

  4. change

    objStream.Open objStream.CharSet = “UTF-8″

    to

    objStream.Open
    objStream.CharSet = “UTF-8″

    Numanuma guy

    May 23, 2008 at 7:08 am

  5. Thank you very much

    Grateful

    June 18, 2008 at 7:48 am

  6. Thanks for the tip. Worked like a charm.

    Ed

    June 25, 2008 at 10:19 am

  7. this code doesnt work

    shri

    July 21, 2010 at 12:49 am

  8. nice

    lucker

    July 14, 2011 at 3:56 am

  9. Thank’s for this tip.

    Here is hte translated version for JScript:

    var adTypeBinary = 1;
    var adSaveCreateOverWrite = 2;
    var adModeReadWrite = 3;

    var objStream = new ActiveXObject(“ADODB.Stream”);
    objStream.Open();
    objStream.CharSet = “UTF-8”;
    objStream.WriteText(content);

    objStream.SaveToFile(filename, adSaveCreateOverWrite);
    objStream.Close();

    Jean-Marc Paratte

    July 28, 2011 at 10:06 am

  10. You need call

    objStream.LoadFromFile filename
    objStream.ReadText

    if file exists to append data

    nthaih

    October 24, 2011 at 11:33 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: