Project

General

Profile

Actions

Bug #566

closed

String encoding error messages are inconsistent

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

Status:
Closed
ruby -v:
Backport:
[ruby-core:18600]

Description

=begin
Please compare:
"abc".encode("UTF-16BE") << "abc"
==> EncodingCompatibilityError: incompatible character encodings: UTF-16BE and US-ASCII
and:
"abc".encode("UTF-16BE") =~ /abc/
==> ArgumentError: incompatible encoding regexp match (US-ASCII regexp with UTF-16BE string)

also handling of broken (illegal) string encodings is not consistent:
"abc".force_encoding("UTF-16BE") =~ /abc/
==> ArgumentError: broken UTF-16BE string
and:
"abc".force_encoding("UTF-16BE") == "abc"
==> false (no error)
and:
"abc".encode("UTF-16BE").count("b".force_encoding("UTF-16BE"))
==> ArgumentError: invalid byte sequence in UTF-16BE
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0