Project

General

Profile

Actions

Feature #565

closed

Encoding::compatible? should also accept Encoding objects as parameters

Added by mike (Michael Selig) over 16 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:18595]

Description

=begin
Some software needs to do transcoding of strings or regexps to be compatible with incoming data from either a file or strings passed as parameters etc. It needs to say things like:

Encoding.compatible?(Encoding.default_external, str)
or:
Encoding.compatible?(io.internal_encoding, Encoding.find("ASCII"))
etc.

It is possible to do this by creating dummy strings in the encodings, and passing those, but in that case Ruby seems to try to optimize them based on content (eg: null strings), and so can say that the strings are compatible when in fact in general the encodings are not.
eg:
Encoding.compatible?("".force_encoding("UTF-16BE"), "".force_encoding("ASCII"))
=> #Encoding:UTF-16BE

So the request is to allow Encoding::compatible? to accept Encoding objects as well as strings and Regexps.
=end

Actions #1

Updated by naruse (Yui NARUSE) over 16 years ago

=begin
Hi,

Michael Selig wrote:

Feature #565: Encoding::compatible? should also accept Encoding objects as parameters
http://redmine.ruby-lang.org/issues/show/565

Author: Michael Selig Status: Open, Priority: Normal

Some software needs to do transcoding of strings or regexps to be compatible with incoming data from either
a file or strings passed as parameters etc. It needs to say things like:

Encoding.compatible?(Encoding.default_external, str) or: Encoding.compatible?(io.internal_encoding,
Encoding.find("ASCII")) etc.

It is possible to do this by creating dummy strings in the encodings, and passing those, but in that case
Ruby seems to try to optimize them based on content (eg: null strings), and so can say that the strings are
compatible when in fact in general the encodings are not. eg:
Encoding.compatible?("".force_encoding("UTF-16BE"), "".force_encoding("ASCII")) => #Encoding:UTF-16BE

So the request is to allow Encoding::compatible? to accept Encoding objects as well as strings and Regexps.

r19357 allows Encoding::compatible? to accept Encoding and IO objects.

--
NARUSE, Yui

=end

Actions #2

Updated by naruse (Yui NARUSE) over 16 years ago

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

=begin
Applied in changeset r19357.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0