title: Perform character operations with shell commands
body: <p>I need to convert a CSV file exported from Mac Excel 2011 to an importable format recognized by a CMS (the solution should not be related, however the import format is for Drupal Feeds module, although the target).</p>
  
  <p>In order to do this currently I need to perform the following operations in Vim:</p>
  
  <pre><code>:%s/\r/\r/g
  :w ++enc=utf8
  </code></pre>
  
  <p>Which basically means:</p>
  
  <ol>
  <li>Convert carriage returns to some sort of universal format 
  <ul>
  <li>Initially as Excel exports them, the carriage return character is represented by <code>^M</code></li>
  <li>the Vim command <code>:%s/\r/\r/g</code> converts them all to a format the CMS recognizes as a carriage return</li>
  </ul></li>
  <li>Convert the character encoding to UTF8.
  <ul>
  <li>As exported initially, the character set is <code>ASCII Extended</code> or something similar.</li>
  </ul></li>
  </ol>
  
  <p>Ideally this process will need to be triggered upon uploading the file as part of the import, which means PHP will trigger the process, whether that has any bearing on the process. However I feel more comfortable at this point handling the solution as a shell script or something similar, but of course PHP solutions are welcome if I can figure out how to hook it into Drupal 7 Feeds.</p>