Project

General

Profile

Actions

Feature #1900

closed

Suggestion: Encoding#ascii_compatible?

Added by candlerb (Brian Candler) over 14 years ago. Updated almost 13 years ago.

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

Description

=begin
An important property of an Encoding is whether it is ASCII-compatible. However as far as I can see, you can only test for this indirectly, e.g.

Encoding.compatible?("a".force_encoding("ISO-8859-1"), "a".force_encoding("US-ASCII"))

So I suggest exposing rb_enc_asciicompat as a property of the Encoding objects themselves.
=end

Actions #1

Updated by runpaint (Run Paint Run Run) over 14 years ago

=begin
There's Encoding::Converter.asciicompat_encoding('UTF-8'). It returns nil if it is; a corresponding ASCII-compatible encoding otherwise.
=end

Actions #2

Updated by phasis68 (Heesob Park) over 14 years ago

=begin
I think Encoding::Converter.asciicompat_encoding method is incomplete.
It cannot be distinguished whether the given encoding is invalid or ASCII-compatible.
Encoding::Converter.asciicompat_encoding("UTF-8") returns nil.
Encoding::Converter.asciicompat_encoding("UTF-0") also returns nil.

=end

Actions #3

Updated by naruse (Yui NARUSE) over 14 years ago

  • Category set to M17N

=begin
This seems reasonable.
How do you think matz?
If ok, I'll add this.
=end

Actions #4

Updated by runpaint (Run Paint Run Run) over 14 years ago

=begin

It cannot be distinguished whether the given encoding is invalid or ASCII-compatible.
Encoding::Converter.asciicompat_encoding("UTF-8") returns nil.
Encoding::Converter.asciicompat_encoding("UTF-0") also returns nil.

Is this intentional or a bug?
=end

Actions #5

Updated by matz (Yukihiro Matsumoto) over 14 years ago

=begin
Hi,

In message "Re: [ruby-core:24800] [Feature #1900] Suggestion: Encoding#ascii_compatible?"
on Fri, 7 Aug 2009 01:40:21 +0900, Yui NARUSE writes:

|This seems reasonable.
|How do you think matz?
|If ok, I'll add this.

It's OK. But can you address the issue mentioned in [ruby-core:24796]
(cannot distinguish ASCII-compatible and invalid)?

						matz.

=end

Actions #6

Updated by naruse (Yui NARUSE) over 14 years ago

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

=begin
Applied in changeset r24480.
=end

Actions #7

Updated by naruse (Yui NARUSE) over 14 years ago

=begin

It cannot be distinguished whether the given encoding is invalid or ASCII-compatible.
Encoding::Converter.asciicompat_encoding("UTF-8") returns nil.
Encoding::Converter.asciicompat_encoding("UTF-0") also returns nil.

Is this intentional or a bug?

Different from methods of Encoding, methods of Encoding::Converter is categorized into transcode.
So their intention is also different.

Encoding::Converter.asciicompat_encoding is made to use when you handle a string encoded in ASCII-incompatible encoding.
You can use this and get an ASCII-compatible encoding which has the same character set, and convert to it, and you can handle that string with Ruby APIs.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0