home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch      Fun with MS-DOS batch files      42,547 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 41,493 of 42,547   
   David Solimano to sean@sean.eternal-september.org   
   Re: change file encoding in batch file   
   15 Oct 16 10:37:55   
   
   From: david@solimano.org   
      
   On Sat, 15 Oct 2016 02:16:51 -0700, sean   
    wrote:   
      
   >On 10/14/2016 11:36 PM, sean wrote:   
   >   
   >This isn't the case in Windows from my testing.   
   >   
   >If a file is already utf-16 and I convert it to utf-16, the new file is   
   >blank.   
   >   
   >iconv: c:\temp\bin\temp.xml: cannot convert   
   >   
   >So knowing this, is there a way to detect the file type so I can skip   
   >files that are already correct?   
      
   Looks like GnuWin32 ships with 'file' which can determine that.   
   There's also a bit of powershell magic here you can plug into.   
      
   http://stackoverflow.com/a/28079177/58074   
      
   It just looks for a BOM to see if it's UTF.  I think UTF-16 should   
   always have a BOM, so you should be good there.   
   --   
   David Solimano   
   david@solimano.org   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca