Bize Ulaşın / Contact Us

VBScript : OpenTextFile Weird/Bad Characters

01 / 07 / 2011 by Scripting Yorum yok / No Comments

I have just experienced a problem while trying to read a text file by vbscript. When I echo lines to screen I saw an empty line shows ÿþ, and other weird/bad characters.
Screen_04 21-Jan-09 14.47

Than I realized the problem is about the file’s encoding. The text file I was trying to read is created by printing characters to a file. (dir c:test.txt).

So don’t forget to define encoding type while opening a file, check the three parameters below that you will use as a paramater for OpenTextFile

Open Using System Default > TristateUseDefault =-2
Open File As Unicode icin > TristateTrue=-1
Open File As ASCII icin > TristateFalse=0

Example:

Const ForReading = 1
Const TristateUseDefault=-2
Dim objFSO
Set objFile = objFSO.OpenTextFile(“C:WDSPendingDevices.txt”, ForReading, True, TristateUseDefault)

( VBScript : OpenTextFile Weird/Bad Characters )

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

*

Kontrol / Control * Time limit is exhausted. Please reload CAPTCHA.