Skip to content

ArgumentError (not fully converted, 23 bytes left) with String.encode! #5681

@bibstha

Description

@bibstha

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
    jruby 9.2.6.0 (2.5.3) 2019-02-11 15ba00b OpenJDK 64-Bit Server VM 12+33 on 12+33 +jit [darwin-x86_64]

  • Operating system and platform (e.g. uname -a)
    MacBookPro Mojave

Problem:

I'm trying to read and convert the following file in utf8
https://github.com/tmm1/ripper-tags/blob/7f31ab7d9009ea2c566e81901cd344b04e6356e1/test/fixtures/encoding.rb

Here is the ruby code that works fine in cruby

# test_encoding.rb
filename = "test/fixtures/encoding.rb"
str = File.open(filename, "r:utf8") { |f| f.read }
str.encode!('utf-16', :invalid => :replace, :undef => :replace)

On jruby it raises an exception

$ ruby test_encoding.rb
ArgumentError: not fully converted, 23 bytes left
  encode! at org/jruby/RubyString.java:6044
   <main> at test.rb:3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions