Skip to content

JRuby does not Handle UTF-8 Source Files #480

@martinvahi

Description

@martinvahi
#!/bin/bash


S_NONASCII_SCRIPT="puts 'Tsitaatsõne'" 

FILE_A="./a.rb"
FILE_B="./b.rb"

echo "$S_NONASCII_SCRIPT"    >  $FILE_A
echo ""  >  $FILE_B

echo "puts 'Start of test.'" >> $FILE_B
echo "require './a.rb'"      >> $FILE_B
echo "puts 'End of test.\n'" >> $FILE_B


echo ""
echo "Running ./a.rb with plain ruby:"
echo ""
`which ruby` -Ku ./a.rb
echo ""
echo "Running ./b.rb with plain ruby:"
echo ""
`which ruby` -Ku ./b.rb
echo ""
echo ""
echo "Running jruby with non-ASCII script directly from console:"
echo ""
`which jruby` -Ku --1.9 -e "$S_NONASCII_SCRIPT"
echo ""
echo ""
echo "Running ./a.rb with jruby:"
echo ""
`which jruby` -Ku --1.9 ./a.rb
echo ""
echo ""
echo "Running ./b.rb with jruby:"
echo ""
`which jruby` -Ku --1.9 ./b.rb
echo ""
echo ""

# The console output of this script, if the bash comments and 
# a single space were removed from the start of the lines:
# 
# Running ./a.rb with plain ruby:
# 
# Tsitaatsõne
# 
# Running ./b.rb with plain ruby:
# 
# Start of test.
# Tsitaatsõne
# End of test.\n
# 
# 
# Running jruby with non-ASCII script directly from console:
# 
# Tsitaatsõne
# 
# 
# Running ./a.rb with jruby:
# 
# SyntaxError: ./a.rb:2: invalid multibyte char (US-ASCII)
# 
# 
# Running ./b.rb with jruby:
# 
# Start of test.
# SyntaxError: /home/ts2/tmp/xx5/test_case/./a.rb:2: invalid multibyte char (US-ASCII)
#   require at org/jruby/RubyKernel.java:991
#    (root) at /home/ts2/m_local/bin_p/Ruby/JRuby/paigaldatult/v_1_7_0/lib/ruby/shared/rubygems/custom_require.rb:1
#    (root) at ./b.rb:3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions