Project

General

Profile

Actions

Backport #5379

closed

the join method of array return different encoding result

Added by saberma (saber ma) over 12 years ago. Updated over 12 years ago.

Status:
Closed
[ruby-core:39776]

Description

ruby-1.9.3-rc1 :001 > [[], "中文"].join
=> "中文"

This is fine. But is the last element is nil, the result is different.

ruby-1.9.3-rc1 :002 > [[], "中文", nil].join
=> "\xE4\xB8\xAD\xE6\x96\x87"

It will cause some gems to raise error: incompatible character encodings: UTF-8 and US-ASCII

This bug can be reproduct in ruby1.9.3 preview1 and rc1, but ruby1.9.2 p180 and p290 is ok.

ruby-1.9.2-p180 :001 > [[], "中文",nil].join
=> "中文"
ruby-1.9.2-p180 :002 > [[], "中文"].join
=> "中文"

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0