Feature #2043
closed
incompatible character encodings
Added by vo.x (Vit Ondruch) over 15 years ago.
Updated over 13 years ago.
Description
=begin
Why the following example fails with the "Encoding::CompatibilityError: incompatible character encodings: Windows-1250 and UTF-8" exception?
s = "\u017Elu\u0165ou\u010dk\u00fd"
a = s.encode 'cp1250'
b = s.encode 'utf-8'
c = a + b
I would expect that if the strings are not in the same encoding, that Ruby will do everything they can to satisfy me, but they just tries if there is possible conversion to ASCII otherwise exception is fired. This is really annoying behavior.
Have you considered to allow such string merge?
=end
- Status changed from Open to Assigned
- Assignee set to naruse (Yui NARUSE)
=begin
Sorry, what is "possible conversion to ASCII" ?
=end
- Target version set to 3.0
=begin
In following example, just characters from US-ASCII are used and in this case the addition works well.
s = 'abc'
a = s.encode 'cp1250'
b = s.encode 'utf-8'
c = a + b
=end
=begin
Ruby 1.9 doesn't automatic conversion.
ASCII character set is a special
because those characters of ASCII compatible encodings are the same characters.
On Ruby 1.9's view, Unicode is not a superset of Windows-1252.
=end
- Status changed from Assigned to Rejected
=begin
On Ruby 1.9's view, Unicode is not a superset of Windows-1252.
Is the "Ruby 1.9's view" somewhere described in detail? I still have the feeling that it is just half baked :/
=end
=begin
Thank you for the links. It was interesting.
I'm looking forward Ruby 2.0 and their automatic conversions, since writing c = a.encode('utf-8') + b.encode('utf-8') to safely concatenate two strings is not sexy at all.
Vit
=end
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0