I am experiencing some confusion in a method Kernel#sprintfin Ruby.
Ruby 1.9 handles encoding differently than Ruby 1.8.
Here are the results I get after, and how they behave in Ruby 1.8:
>> RUBY_VERSION
=> "1.8.7"
>> sprintf("%c", 88599)
=> "\027"
Here's how it works in Ruby 1.9:
1.9.3p194 :001 > RUBY_VERSION
=> "1.9.3"
1.9.3p194 :002 > sprintf("%c", 88599)
=> "\u{15A17}"
If I use a magic comment to set the encoding to a binary file (ascii-8bit), I get an error message:
1.9.3p194 :001 > RUBY_VERSION
=> "1.9.3"
1.9.3p194 :002 >
1.9.3p194 :003 > sprintf("%c", 88599)
RangeError: 88599 out of char range
from (irb):3:in `sprintf'
from (irb):3
from /Users/lisinge/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
I also tried this with Ruby 1.9.2, so it doesn't seem to apply to 1.9.3.
Maybe I'm doing something wrong? I am not very familiar with the method Kernel#sprintf.
I use the smpp library called ruby-smpp, which can be found on github . This is the method send_concat_mton line # 47 that works when I try to run it in Ruby 1.9.3.
, - .