Hi,

Sorry for being late.

In message "Re: [ruby-core:18611] Re: [Bug #566] String encoding error messages are inconsistent"
    on Tue, 16 Sep 2008 07:38:13 +0900, "Michael Selig" <michael.selig / fs.com.au> writes:

|I would expect these to both be "EncodingCompatibilityError"

OK, I will.

|> |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
|
|I guess in this group there are 2 issues:
|1) (This is minor) I would expect both error messages to have the same  
|text - I think the "invalid byte sequence in XXX" is the better.
|2) It seems inconsistent to me that the 1st & 2nd expressions look almost  
|the same as each other (a regexp match & a string compare) yet only the  
|regexp match raises an error.

(1) I changed messages more consistent.
(2) "=~" and "==" are different operation.  The former requires more
    precondition than the latter, e.g. type of both operands should be
    strings or regexps, and they should be encoding compatible.  On
    the other hands, the latter .  They should give either true or
    false, and should not raise any exception.

							matz.