jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
JRuby
  • JRuby
  • JRUBY-2911

Encoding problem

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.3
  • Fix Version/s: JRuby 1.6.4
  • Component/s: Java Integration
  • Labels:
    None
  • Environment:
    Windows XP
  • Number of attachments :
    0

Description

# 1. JRuby source code
# jruby02.rb
require 'java'
include_class 'java.lang.String' do |package,name|
  "J#{name}"
end

ResourceBundle = java.util.ResourceBundle
Locale = java.util.Locale

lang = JString.new 'pt'
country = JString.new 'BR'

cLocale = Locale.new lang, country
msg = ResourceBundle.get_bundle 'MessagesBundle', cLocale

puts msg.get_string 'greetings'
puts msg.get_string 'welcome'
# 2. The MessagesBundle_pt_BR.properties is 
# in the same folder as the jruby02.rb program
# MessagesBundle_pt_BR.properties
greetings = Ol\u00a0
welcome = Benvindo ao Brazil
# 3. Executed the program
# jruby jruby02.rb
# and the output is
Ol 
Benvindo ao Brazil

# whereas the outputs should have been:
Olá
Benvindo ao Brazil
# The equivalent Java program works properly
import java.util.*;
public class InternationalizationEx
{
  public static void main(String[] args)
  {
    String lang, country;
    Locale cLocale;
    ResourceBundle msg;

    lang = new String("pt");
    country = new String("BR");

    cLocale = new Locale(lang, country);
    msg = ResourceBundle.getBundle("MessagesBundle", cLocale);

    System.out.println(msg.getString("greetings"));
    System.out.println(msg.getString("welcome"));
  }
}

Some encoding problem in JRuby?

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Thomas E Enebo added a comment - 26/Aug/08 4:09 PM

If the message bundle resource file is in UTF-8 encoding then things display ok. The example uses \uxxxxx unicode format which does not work. We will have to figure out exactly what is happening, but it will not happen for 1.1.4. Bumping to 1.1.5.

Show
Thomas E Enebo added a comment - 26/Aug/08 4:09 PM If the message bundle resource file is in UTF-8 encoding then things display ok. The example uses \uxxxxx unicode format which does not work. We will have to figure out exactly what is happening, but it will not happen for 1.1.4. Bumping to 1.1.5.
Hide
Permalink
Charles Oliver Nutter added a comment - 30/Oct/08 2:34 AM

I'm afraid this one never got addressed in 1.1.5...too much to do and not enough people to do it. Maybe in the next cycle we'll be able to get to it. More cases and more exploration would really help.

Show
Charles Oliver Nutter added a comment - 30/Oct/08 2:34 AM I'm afraid this one never got addressed in 1.1.5...too much to do and not enough people to do it. Maybe in the next cycle we'll be able to get to it. More cases and more exploration would really help.
Hide
Permalink
Nick Sieger added a comment - 17/Aug/09 4:29 PM

I can verify this is still a problem. However, I had to use the following in the portuguese message bundle for the proper accented character to print out using the Java program:

greetings = Ol\u221a\u00b0
Show
Nick Sieger added a comment - 17/Aug/09 4:29 PM I can verify this is still a problem. However, I had to use the following in the portuguese message bundle for the proper accented character to print out using the Java program: greetings = Ol\u221a\u00b0
Hide
Permalink
Hiro Asari added a comment - 21/Oct/11 12:11 AM

Recent improvements should have this fixed. I suppose it should be tested on Windows, but my tests on Mac OS X revealed identical outputs for JRuby and Java.

Show
Hiro Asari added a comment - 21/Oct/11 12:11 AM Recent improvements should have this fixed. I suppose it should be tested on Windows, but my tests on Mac OS X revealed identical outputs for JRuby and Java.

People

  • Assignee:
    Hiro Asari
    Reporter:
    Satish Talim
Vote (2)
Watch (3)

Dates

  • Created:
    10/Aug/08 2:17 AM
    Updated:
    03/Aug/12 2:35 PM
    Resolved:
    21/Oct/11 12:11 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.