[Kde-bindings] [bindings] [Bug 339796] New: QtRuby Qt::Application.translate returns strings with ASCII8BIT encoding instead of UTF-8

Gavin Kidtner gavin_kde at phrogz.net
Wed Oct 8 20:45:55 UTC 2014


https://bugs.kde.org/show_bug.cgi?id=339796

            Bug ID: 339796
           Summary: QtRuby Qt::Application.translate returns strings with
                    ASCII8BIT encoding instead of UTF-8
           Product: bindings
           Version: unspecified
          Platform: MS Windows
               URL: https://github.com/ryanmelt/qtbindings/issues/99
                OS: MS Windows
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: kde-bindings at kde.org
          Reporter: gavin_kde at phrogz.net

The Ruby code produced by rbuic4 (compiling a *.ui to a *.rb) creates code like
this:

@menuOpen.text = Qt::Application.translate("MainWin", "Open\342\200\246", nil,
Qt::Application::UnicodeUTF8)

The result of this code is broken characters in the menu on Windows 7. The
source of the problem is that the `translate` menu returns a Ruby string
instance whose `encoding` is set to ASCII8BIT (aka binary) instead of UTF-8.


[1] https://github.com/ryanmelt/qtbindings

Reproducible: Always

Steps to Reproduce:
a) Run this code (can be from Ruby's interactive REPL, `irb`):
require 'qt'
p Qt::Application.translate('Main',"Open\342\200\246", nil,
Qt::Application::UnicodeUTF8).encoding

b) Alternatively, create a .ui in Qt Designer with Unicode characters in the
menu like an ellipsis, compile using `rbuic4`, run the test application, and
open the menu.

Actual Results:  
a) The output: #<Encoding:ASCII-8BIT>
b) Incorrect character(s) appear in the menu.

Expected Results:  
a) The output: #<Encoding:UTF-8>
b) The Unicode characters typed appear in the menu.

Qt 4.8.6
Ruby 2.0.0p576 (32-bit)
qtbindings (4.8.6.0 x86-mingw32)
qtbindings-qt  (4.8.6.0 x86-mingw32)
Windows 7x64

The workaround for this is to redefine the method to force the encoding of the
result:

class Qt::Application
  def self.translate(*a,&b)
    method_missing(:translate,*a,&b).force_encoding('utf-8')
  end
end

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the Kde-bindings mailing list