Results 1 to 3 of 3

Thread: Determine if a file is Unicode or ANSI

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Determine if a file is Unicode or ANSI

    I have a bunch of INF files that I'm trying to work with. The problem I'm finding is that some of them are Unicode format and some are ANSI.


    I can open and read in the file fine, but when I try to write out to it, my script crashes.

    VB Code:
    1. Set outFile = FS.GetFile(FSFile.Path).OpenAsTextStream(2, -2) 'save INF in ANSI format to save space
    2. outFile.Writeline FileString 'write the modified text
    3. outFile.Close 'close file handle
    4. set OutFile = Nothing

    If I write a null value to the file it seems to work fine.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Re: Determine if a file is Unicode or ANSI

    I also found out that it is crashing due to invalid characters. The Unicode format supports a larger character set than ANSI. The INF file I have contains Chinese characters which are causing the script to choke when it tries to write them out to the ANSI file.

    Now, the question is... is there a way to convert these Unicode characters, without going through each and every character in the string and testing it? Ugh... there must be an easier way.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    NJ, USA
    Posts
    326

    Re: Determine if a file is Unicode or ANSI

    Heck I'll even settle for a batch file if it gets the job done.
    VB.NET 2005 Express with .Net 2.0
    C# 2010 .Net 4.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width