Convert ellipsis to utf-8

Hi,

I have a string consisting of 3 periods: “…”. I want to convert it
into a single utf-8 character

I tried Iconv.iconv(‘utf-8’, ‘iso-8859-1’, ‘…’) but that didnt
work… any clues?

On 01.10.2010 00:35, Rahul Thathoo wrote:

I have a string consisting of 3 periods: “…”. I want to convert it
into a single utf-8 character http://www.fileformat.info/info/unicode/char/2026/index.htm

I tried Iconv.iconv(‘utf-8’, ‘iso-8859-1’, ‘…’) but that didnt
work… any clues?

I think I’d simply go with:

ruby-1.9.2-p0 > puts “foo…bar”.gsub!(’…’, “\u2026”)
foo…bar

I wouldn’t except iconv() to know how to handle this. I’m not an expert
but I’ve never seen a conversion creating “multiple characters”.
“Multiple bytes”, yes, but not “characters”.

HTH,

  • Markus

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs