title: How to make sure all my source files stay UTF-8 with Unix line endings?
body: <p>I'm looking for some command-line tools for Linux that can help me detect and convert files from character sets like <em>iso-8859-1</em> and <em>windows-1252</em> to <em>utf-8</em> and from Windows line endings to Unix line endings.</p>
  
  <p>The reason I need this is that I'm working on projects on Linux servers via SFTP with editors on Windows (like Sublime Text) that just constantly screws these things up. Right now I'm guessing about half my files are <em>utf-8</em>, the rest are <em>iso-8859-1</em> and <em>windows-1252</em> as it seems Sublime Text is just picking character set by which symbols the file contains when I save it. The line endings are ALWAYS Windows line endings even though I've specified in the options that default line endings are <em>LF</em>, so about half of my files have <em>LF</em> and half are <em>CRLF</em>.</p>
  
  <p>So I would need at least a tool that would recursively scan my project folder and alert me of files that deviate from <em>utf-8</em> with <em>LF</em> line endings so I could manually fix that before I commit my changes to GIT.</p>
  
  <p>Any comments and personal experiences on the topic would also be welcome.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p><em><strong>Edit:</em></strong> I have a temporary solution in place where I use <code>tree</code> and <code>file</code> to output information about every file in my project, but it's kinda wonky. If I don't include the <code>-i</code> option for <code>file</code> then a lot of my files gets different output like <em>ASCII C++ program text</em> and <em>HTML document text</em> and <em>English text</em> etc:</p>
  
  <pre>
  $ tree -f -i -a -I node_modules --noreport -n | xargs file | grep -v directory
  ./config.json:              ASCII C++ program text
  ./debugserver.sh:           ASCII text
  ./.gitignore:               ASCII text, with no line terminators
  ./lib/config.js:            ASCII text
  ./lib/database.js:          ASCII text
  ./lib/get_input.js:         ASCII text
  ./lib/models/stream.js:     ASCII English text
  ./lib/serverconfig.js:      ASCII text
  ./lib/server.js:            ASCII text
  ./package.json:             ASCII text
  ./public/index.html:        HTML document text
  ./src/config.coffee:        ASCII English text
  ./src/database.coffee:      ASCII English text
  ./src/get_input.coffee:     ASCII English text, with CRLF line terminators
  ./src/jtv.coffee:           ASCII English text
  ./src/models/stream.coffee: ASCII English text
  ./src/server.coffee:        ASCII text
  ./src/serverconfig.coffee:  ASCII text
  ./testserver.sh:            ASCII text
  ./vendor/minify.json.js:    ASCII C++ program text, with CRLF line terminators
  </pre>
  
  <p>But if I do include <code>-i</code> it doesn't show me line terminators:</p>
  
  <pre>
  $ tree -f -i -a -I node_modules --noreport -n | xargs file -i | grep -v directory
  ./config.json:              text/x-c++; charset=us-ascii
  ./debugserver.sh:           text/plain; charset=us-ascii
  ./.gitignore:               text/plain; charset=us-ascii
  ./lib/config.js:            text/plain; charset=us-ascii
  ./lib/database.js:          text/plain; charset=us-ascii
  ./lib/get_input.js:         text/plain; charset=us-ascii
  ./lib/models/stream.js:     text/plain; charset=us-ascii
  ./lib/serverconfig.js:      text/plain; charset=us-ascii
  ./lib/server.js:            text/plain; charset=us-ascii
  ./package.json:             text/plain; charset=us-ascii
  ./public/index.html:        text/html; charset=us-ascii
  ./src/config.coffee:        text/plain; charset=us-ascii
  ./src/database.coffee:      text/plain; charset=us-ascii
  ./src/get_input.coffee:     text/plain; charset=us-ascii
  ./src/jtv.coffee:           text/plain; charset=us-ascii
  ./src/models/stream.coffee: text/plain; charset=us-ascii
  ./src/server.coffee:        text/plain; charset=us-ascii
  ./src/serverconfig.coffee:  text/plain; charset=us-ascii
  ./testserver.sh:            text/plain; charset=us-ascii
  ./vendor/minify.json.js:    text/x-c++; charset=us-ascii
  </pre>
  
  <p>Also why does it display <em>charset=us-ascii</em> and not <em>utf-8</em>? And what's <em>text/x-c++</em>? Is there a way I could output only <code>charset=utf-8</code> and <code>line-terminators=LF</code> for each file?</p>