When I first had a look at the Iconv class in Ruby,
using a block to handle characters that can't be translated
or illegal byte sequences seemed the obvious thing that
was missing.

At 04:12 07/10/11, Nobuyoshi Nakada wrote:
>Hi,
>
>At Thu, 11 Oct 2007 02:20:11 +0900,
>Eugene Ossintsev wrote in [ruby-core:12579]:
>> I noticed Ruby 1.9 had the class Iconv improved. In 1.9 it became
>> possible to discard characters that cannot be converted from one
>> encoding to another for some reason. So, it's like in GNU iconv
>> utility with the option '-c' as I understand. It's much better than in
>> 1.8 where it is aborted with an exception in such a case.
>
>> By the way, are there any plans to augment exception handling so that
>> it would be possible to handle illegal characters even more flexible,
>> say, not discarding them but replacing with some character or giving
>> more information on where it stopped or something?
>
>Once I thought to use a block for exception handling.
>
>e.g.
>  Iconv.open("utf-8", "euc-jp") {|cd|
>    cd.iconv("\xa1\xa2") {|errinfo| ...}
>  }

I don't understand this double block structure, can you explain?

Regards,    Martin.

>or,
>
>  Iconv.open("utf-8", "euc-jp", Iconv::IllegalSequence => proc {|errinfo| ...}) {
>    ...
>  }
>
>Any thoughts?
>
>-- 
>Nobu Nakada


#-#-#  Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-#  http://www.sw.it.aoyama.ac.jp       mailto:duerst / it.aoyama.ac.jp