Bug 339796 - QtRuby Qt::Application.translate returns strings with ASCII8BIT encoding instead of UTF-8
Summary: QtRuby Qt::Application.translate returns strings with ASCII8BIT encoding inst...
Status: RESOLVED UNMAINTAINED
Alias: None
Product: bindings
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: kde-bindings
URL: https://github.com/ryanmelt/qtbinding...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-08 20:45 UTC by Gavin Kistner
Modified: 2022-12-22 06:49 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin Kistner 2014-10-08 20:45:55 UTC
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
Comment 1 Andrew Crouthamel 2018-11-12 02:48:22 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 2 Andrew Crouthamel 2018-11-21 04:31:40 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Mathieu Jobin 2022-12-22 06:49:16 UTC
QtRuby only existed for Qt4 and Korundum, which never got updated for 5.x

This is unmaintained and any effort towards QtRuby for Qt6 will be from scratch.

Therefore, closing this ticket