[DRE-maint] Bug#799194: ruby-gettext: may return rubbish when LANGUAGE is set and LC_CTYPE='C'

Francesco Poli (wintermute) invernomuto at paranoici.org
Wed Sep 16 17:54:43 UTC 2015


Package: ruby-gettext
Version: 3.1.6-1
Severity: normal

Hello!
As discussed on bug #799050 [1] and on debian-ruby at l.d.o [2], I've
found a weird behavior of ruby-gettext.

[1] https://bugs.debian.org/799050#22
[2] https://lists.debian.org/debian-ruby/2015/09/msg00042.html

Steps to reproduce (with apt-listbugs/0.1.17 installed)

  $ locale
  LANG=en_US.UTF-8
  LANGUAGE=en_US:en
  LC_CTYPE="en_US.UTF-8"
  LC_NUMERIC="en_US.UTF-8"
  LC_TIME="en_US.UTF-8"
  LC_COLLATE="en_US.UTF-8"
  LC_MONETARY="en_US.UTF-8"
  LC_MESSAGES="en_US.UTF-8"
  LC_PAPER="en_US.UTF-8"
  LC_NAME="en_US.UTF-8"
  LC_ADDRESS="en_US.UTF-8"
  LC_TELEPHONE="en_US.UTF-8"
  LC_MEASUREMENT="en_US.UTF-8"
  LC_IDENTIFICATION="en_US.UTF-8"
  LC_ALL=
  $ ruby -e 'require "gettext" ; GetText::bindtextdomain("apt-listbugs") ; puts GetText.gettext("Forwarded")'
  Forwarded
  $ LANGUAGE='fr' ruby -e 'require "gettext" ; GetText::bindtextdomain("apt-listbugs") ; puts GetText.gettext("Forwarded")'
  Transférés
  $ LANGUAGE='fr' ruby -e 'require "gettext" ; GetText::bindtextdomain("apt-listbugs") ; puts GetText.gettext("Forwarded").encoding'
  UTF-8

Everything's fine so far.

  $ LANGUAGE='fr' LC_CTYPE='C' ruby -e 'require "gettext" ; GetText::bindtextdomain("apt-listbugs") ; puts GetText.gettext("Forwarded").encoding'
  ASCII-8BIT

Here the encoding is wrong and the content of the returned string
includes rubbish characters:

  $ LANGUAGE='fr' LC_CTYPE='C' irb
  irb(main):001:0> require "gettext"
  => true
  irb(main):002:0> GetText::bindtextdomain("apt-listbugs")
  [...]
  irb(main):003:0> GetText.gettext("Forwarded")
  => "Transf\xC3\xA9r\xC3\xA9s"
  irb(main):004:0> exit

The awkward finding is that, if I print the string, it gets magically
converted back to UTF-8:

  $ LANGUAGE='fr' LC_CTYPE='C' ruby -e 'require "gettext" ; GetText::bindtextdomain("apt-listbugs") ; puts GetText.gettext("Forwarded")'
  Transférés

But I cannot compute the width of the string with ruby-unicode:

  $ LANGUAGE='fr' LC_CTYPE='C' ruby -e 'require "gettext" ; GetText::bindtextdomain("apt-listbugs") ; require "unicode" ; puts Unicode.width(GetText.gettext("Forwarded"))'
  -e:1:in `width': "\xC3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
          from -e:1:in `<main>'

What's wrong?
Please investigate and/or forward my bug report upstream.

Thanks for your time!

  
-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (800, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.1.0-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Init: sysvinit (via /sbin/init)

Versions of packages ruby-gettext depends on:
ii  ruby                        1:2.1.5.1
ii  ruby-locale                 2.1.0-3
ii  ruby-text                   1.3.0-1
ii  ruby2.1 [ruby-interpreter]  2.1.5-4
ii  ruby2.2 [ruby-interpreter]  2.2.3-1

ruby-gettext recommends no packages.

ruby-gettext suggests no packages.

-- debconf-show failed



More information about the Pkg-ruby-extras-maintainers mailing list