Projects

Ticket #94 (closed defect: fixed)

Opened 20 months ago

Last modified 2 months ago

Bug with non-ASCII in the regular expressions

Reported by: vincent.isambart@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.5
Component: MacRuby Keywords:
Cc:

Description

The following code source displays correctly "あ" in both 1.9 and 1.8 but it wrongly displays "" in MacRuby. I think the reason is that the regexps created with Oniguruma are always created with an ASCII encoding in MacRuby (shouldn't it be UTF-8 as all source code files are handled as UTF-8?).

# encoding: utf-8 version = RUBY_VERSION.sub(/(\d+\.\d+)\.\d+/, '\1').to_f $KCODE = 'u' if version <= 1.8 # remove the warning we get in 1.9 for using $KCODE m = /あ/.match('あ') p m[0]

Change History

Changed 20 months ago by vincent.isambart@…

I forgot to put the code in a code block, so here it is once again. (I also removed the version test as it only makes it less readable)

# encoding: utf-8
$KCODE = 'u' # for Ruby 1.8
m = /あ/.match('あ')
p m[0]

Changed 20 months ago by lsansonetti@…

  • milestone set to MacRuby 0.3

Changed 19 months ago by lsansonetti@…

  • milestone changed from MacRuby 0.3 to MacRuby 0.4

Changed 5 months ago by hiroshi3110@…

This doesn't seem to resolved even in MacRuby 0.5 (trunk r82747).

Changed 2 months ago by lsansonetti@…

  • milestone changed from MacRuby 0.4 to MacRuby 0.5

Changed 2 months ago by lsansonetti@…

  • status changed from new to closed
  • resolution set to fixed

Fixed in r3189.

$ cat t.rb 
# encoding: utf-8
p 'あ'.match(/あ/)
p 'あいあいあいあいあ'.scan(/あ/)
$ ./miniruby t.rb 
#<MatchData "あ">
["あ", "あ", "あ", "あ", "あ"]
Note: See TracTickets for help on using tickets.