Allow specifying the output encoding in the template module (#42171)

Allow specifying the source and destination files' encodings in the template module

* Added output_encoding to the template module, default to utf-8
* Added documentation for the new variables
* Leveraged the encoding argument on to_text() and to_bytes() to keep the implementation as simple as possible
* Added integration tests with files in utf-8 and windows-1252 encodings, testing all combinations
* fix bad smell test by excluding windows-1252 files from the utf8 checks
* fix bad smell test by excluding valid files from the smart quote test
This commit is contained in:
Julien Champseix 2018-07-25 22:10:40 +02:00 committed by Toshio Kuratomi
commit 19dc267e4c
8 changed files with 44 additions and 1 deletions

View file

@ -106,6 +106,13 @@ options:
may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)). As of
version 2.6, the mode may also be the special string C(preserve). C(preserve) means that
the file will be given the same permissions as the source file."
output_encoding:
description:
- Overrides the encoding used to write the template file defined by C(dest).
- It defaults to C('utf-8'), but any encoding supported by python can be used.
- The source template file must always be encoded using C('utf-8'), for homogeneity.
default: 'utf-8'
version_added: "2.7"
notes:
- For Windows you can use M(win_template) which uses '\\r\\n' as C(newline_sequence).
- Including a string that uses a date in the template will result in the template being marked 'changed' each time