getting invalid procedure call or argument in vbscript

后端 未结 2 1549
迷失自我
迷失自我 2020-12-02 02:20

I have the below code..I am getting an invalid call or procedure at this statement txsOutput.Writeline txsInput1.ReadAll ..The combination file is ust a text file which has

2条回答
  •  旧巷少年郎
    2020-12-02 02:42

    The error 5 when calling TextStream.WriteLine is typically caused by trying to write data the TextStream can't encode:

    Trying to write "U+1F00 ἀ e1 bc 80 GREEK SMALL LETTER ALPHA WITH PSILI" to a stream opened with/for 'ASCII' encoding:

    >> Set f = goFS.CreateTextFile(".\tmp.txt")
    >> f.WriteLine "AÄ"
    >>  --- no news here means: written ---
    >> f.WriteLine ChrW(&H1F00)
    >>
    Error Number:       5
    Error Description:  Invalid procedure call or argument
    

    To prove this:

    >> f.close
    >> Set f = goFS.CreateTextFile(".\tmp.txt", True, True) ' overwrite, unicode
    >> f.WriteLine ChrW(&H1F00)
    >>
    >> --- no news are good news --
    

    As the data source (.ReadAll()) seems to come from the WWW, it's probable that it contains non ASCII/ANSI text. Be warned though, just opening the output file for Unicode (=UTF-16) won't help if the input is UTF-8 slurped by .ReadAll() on a ASCII Textstream.

提交回复
热议问题