Re: What's wrong with my line counter script?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Eric Bragas" <ericbragas@xxxxxxxxx> wrote in message
news:19b0be87-0ed9-4b4f-ac27-2e7bce071e18@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,

Below is the contents of my linecounter.vbs file, which I hoped was
going to be useful in telling me how many lines a text file
includes,
but seems to max out at 65,000 (give or take) even though I know my
files are over 800,000 lines of text. Any suggestions? I'm
obviously
oversimplifying or else this wouldn't be a problem.

Thanks,
Eric

----linecounter.vbs--------------------------------------------
Dim objArgs
Set objArgs = WScript.Arguments

TgtFile = objArgs(0)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(TgtFile)
ra = f.ReadAll
msg = objArgs(0) & vbcrlf
msg = msg & " line count: " & f.Line

WScript.Echo msg
--(end)------------------------------------------------------------

You are creating the textstream object, f, without specifying a
format, so it defaults to ASCII, according to the documentation. If
the file happens to actually be formatted as Unicode, then you may
have problems reading it properly.

You could read the first two characters (as ASCII) -- I've never seen
a Unicode file read fail in the first two characters. If they are hex
FF FE or FE FF, then the file system thinks it is Unicode and you may
have problems, unless you specify the format as Unicode.

-Paul Randall


.



Relevant Pages

  • Re: ASCII Character to Text Conversion
    ... Does anyone know of any functionality that will convert the ASCII ... Please, everyone who does this, stop using the phrase "ASCII format." ... An "encoding scheme" is nothing more than a translation matrix, ... All ACSII characters can be represented with a single byte. ...
    (microsoft.public.vb.general.discussion)
  • Re: Enhanced Unicode support for "Go" tools
    ... Right, you know ASCII? ... accent characters used in French and other European ... UNICODE isn't just about all the different alphabets out ... out wrongly because the character set the file was written in is ...
    (alt.lang.asm)
  • Re: ASCII Requires a Temporary Substitution During Encryption.
    ... ASCII has now been replaced by Unicode: ... makes ascii 00 and then the 94 standard characters ...
    (sci.crypt)
  • Re: Unicode Support
    ... > | single bit extra from ASCII for any ordinary ASCII characters... ... UNICODE character then check what "range" it's in with the table ... 7-bit ASCII characters are encoded in exactly the same way in UTF-8 ... All non-ASCII characters use a multi-byte sequence ...
    (alt.lang.asm)
  • Re: 128 bit password
    ... AdMod is ascii based, it doesn't write unicode. ... If I used the unicode version of ldap_mod it would likely be limited to 127 unicode characters. ... Joe Richards Microsoft MVP Windows Server Directory Services ...
    (microsoft.public.security)