From 46e3a2349e9eef4001db8be9581fae9dfbccaf14 Mon Sep 17 00:00:00 2001 From: Geoff Williams Date: Tue, 14 Mar 2017 01:24:36 +1100 Subject: (#FM-6068) allow file encoding to be specified (#726) * (#FM-6068) allow file encoding to be specified Add a new parameter `encoding` to allow non UTF-8 files to specify a file encoding. This prevents receiving the error message "invalid byte sequence in UTF-8" when special characters that are not UTF-8 encoded appear in the input stream, such as the copyright symbol. * (#FM-6068) allow file encoding to be specified Added docs and tests as requested --- lib/puppet/provider/file_line/ruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/provider/file_line') diff --git a/lib/puppet/provider/file_line/ruby.rb b/lib/puppet/provider/file_line/ruby.rb index beeb430..fbf7d8e 100644 --- a/lib/puppet/provider/file_line/ruby.rb +++ b/lib/puppet/provider/file_line/ruby.rb @@ -40,7 +40,7 @@ Puppet::Type.type(:file_line).provide(:ruby) do # file; for now assuming that this type is only used on # small-ish config files that can fit into memory without # too much trouble. - @lines ||= File.readlines(resource[:path]) + @lines ||= File.readlines(resource[:path], :encoding => resource[:encoding]) end def match_regex -- cgit v1.2.3