Hi Andy,

On Wed, Jan 29, 2014 at 10:28 AM, Andy Spiegl <puppet.a...@spiegl.de> wrote:

> Following up on my own post:
>
> > One has to patch this file (on ALL client PCs!):
> >  C:/Program Files (x86)/Puppet Labs/Puppet/facter/lib/facter/timezone.rb
> > ----------------------------
> >   +     Iconv.iconv("UTF-8", "windows-1250",Time.new.zone)
> >   -     Time.new.zone
> > ----------------------------
>
> I just found that iconv is deprecated in ruby and one is supposed to
> use String#encode instead.  Otherwise "puppet --agent --test" shows a
> deprecation warning at every run.
>

We started bundling ruby 1.9 into the Puppet 3.2 MSI, so you are safe to
call String#encode provided you are using that version or newer, and it
sounds like you are. For anyone else on an older version, e.g. 3.1, you'll
want to use Iconv, as String#encode doesn't exist in ruby 1.8


> Okay, did that.  Now my timezone.rb looks like this:
> ----------------------------
> Facter.add("timezone") do
>   setcode do
>     Time.new.zone.encode("UTF-8", "windows-1250")
>

This assumes Time.new.zone returns a string encoded with the Windows-1250
code page. You are probably better off omitting the source encoding, since
ruby should already know what it is:

       Time.new.zone.encode("UTF-8")

The only time I would recommend specifying the source encoding is if ruby
gets it wrong, e.g. ruby claims the String is US-ASCII when you know for
certain it's UTF-16LE[1].

  end
> end
> ----------------------------
>
>
Also, starting in facter 2, all fact values will be UTF-8 encoded before
serializing them to the puppet master. As we get closer to RC status, it
would be great if you could help test facter on your systems.

Josh

[1] https://bugs.ruby-lang.org/issues/8943

-- 
Josh Cooper
Developer, Puppet Labs

*Join us at PuppetConf 2014, September 23-24 in San Francisco - *
http://bit.ly/pupconf14

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CA%2Bu97um8EOOn%2BU6kgL6rqZo1XZGYPqzfYfg42w6VYzA9NC4vhg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to