# Templates: how to handle file encoding and line endings?

**URL:** <https://forum.ansible.com/t/templates-how-to-handle-file-encoding-and-line-endings/25752>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [October 16, 2017, 7:53am UTC](https://forum.ansible.com/t/templates-how-to-handle-file-encoding-and-line-endings/25752 "2017-10-16T07:53:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.lehmann](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@thomas.lehmann](https://forum.ansible.com/u/thomas.lehmann)\
**Post date:** [October 16, 2017, 7:53am UTC](https://forum.ansible.com/t/templates-how-to-handle-file-encoding-and-line-endings/25752/1 "2017-10-16T07:53:41Z")

</div>

Hi,

I’m looking forward to **migrate a large configuration package** to Ansible.  
With a verification script we check that the finally distributed files are the  
same as we have without Ansible. In first phase we moved everything  
into the template folder of the role; reducing configuration code with Jinja  
templating comes in next phase.

So with first phase (as mentioned) we detected following problems:

a) **Line endings** : We have files with different line endings (Windows and Linux)  
but the Ansible template module translates all in one (default: Linux).  
We have been able to workaround writing a filter plugin but probably there  
should be an option like “keep” in addition to given ones in field “newline\_sequence”.  
(feature request)

b) **File encoding** : Usually we have ASCII files for configuration but a few ones do have  
ISO-8859. We detected that final file is converted to UTF-8. I don’t see an option to  
specify encoding. **Any ideas how to handle it?**

kind regards,  
Thomas
