Project

General

Profile

Actions

Bug #5968

closed

Encoding.compatible? with binary string

Added by john_firebaugh (John Firebaugh) about 12 years ago. Updated about 12 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
Backport:
[ruby-core:42354]

Description

=begin
According to #5920:

The original meaning of Encoding.compatible?(str1, str2) is the encoding of concatenated string.
In other codes, it is
str = str1.dup.concat str2
str.encoding <- this!

But observe:
a = "a".force_encoding("binary")
b = "b".force_encoding("us-ascii")
a.dup.concat(b).encoding #=> #Encoding:ASCII-8BIT
Encoding.compatible?(a, b) #=> #Encoding:US-ASCII

I believe the latter should return #Encoding:ASCII-8BIT.
=end

Actions #1

Updated by naruse (Yui NARUSE) about 12 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34433.
John, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • encoding.c (rb_enc_compatible): return ASCII-8BIT even if 2nd string
    is ascii only string. [ruby-core:42354] [Bug #5968]
Actions

Also available in: Atom PDF

Like0
Like0