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


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 *

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.