Answered encoding files

  • Saturday, October 20, 2012 5:39 PM
     
     

    Hi,

    I have a folder with 500 files .dat and i need to know what encoding have, because if it is ANSI i must convert it to UTF-8.

    How can i cycle through all the files and that prospective customers that denba converting are stored in a folder called ./FORCONVERT?

    Thanks

All Replies

  • Saturday, October 20, 2012 5:51 PM
     
     
    Use a script to examine the first three bytes. If they are EF BB BF then it is a UTF-8 file. Both VB Script and PowerShell can do this with ease.
  • Sunday, October 21, 2012 8:29 AM
     
     

    Hi,

    Is there any example in the repository?

  • Sunday, October 21, 2012 9:40 AM
     
     Answered
    You probably need to search the repository yourself or learn the basics of scripting (which we all had to do).
  • Sunday, October 21, 2012 3:02 PM
     
      Has Code

    Hi,

    I have a folder with 500 files .dat and i need to know what encoding have, because if it is ANSI i must convert it to UTF-8.

    How can i cycle through all the files and that prospective customers that denba converting are stored in a folder called ./FORCONVERT?

    Thanks


    Unfortunaly there is no easy way to do this.  I recommend just opening all files and saving them aas UTF-8 using PowerShell.  VBScript has only minimal support for Unicode.

    When a file is opened in 'text' mode the type is automatically detected.  You can force a save to a new type but there is no way to force an in-place conversion.

    dir e:\testa\convert\* |
        %{
           $text=cat $_
           $name=$_.Name
           $text|out-file e:\testa\converted\$name -encoding UTF8
         }


    ¯\_(ツ)_/¯