Skip to content

String#unpack: Unpacked string should not have an encoding #4481

@janlelis

Description

@janlelis

Environment

  • ruby -v jruby 9.1.8.0-SNAPSHOT (2.3.1) 2017-02-06 3f97c7a Java HotSpot(TM) 64-Bit Server VM 25.111-b14 on 1.8.0_111-b14 +indy +jit [linux-x86_64]
  • uname -a Linux ok 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

  • Should not set any encoding on the unpacked string, since it is an unknown binary string
  • MRI example with ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]:
$ ruby -e 'p "1".encoding; p "1".unpack("a*")[0].encoding'
#<Encoding:UTF-8>
#<Encoding:ASCII-8BIT>

Actual Behavior

  • JRuby seems to convert to my encoding implicitly:
$ ruby -e 'p "1".encoding; p "1".unpack("a*")[0].encoding'
#<Encoding:UTF-8>
#<Encoding:UTF-8>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions