public
Description: BDD that talks to domain experts first and code second
Homepage: http://cukes.info/
Clone URL: git://github.com/aslakhellesoy/cucumber.git
Click here to lend your support to: cucumber and make a donation at www.pledgie.com !
cucumber / lib / cucumber / formatter / unicode.rb
100644 35 lines (30 sloc) 0.835 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Require this file if you need Unicode support.
require 'cucumber/platform'
require 'cucumber/formatter/ansicolor'
 
$KCODE='u' unless Cucumber::RUBY_1_9
 
if Cucumber::WINDOWS_MRI && `chcp` =~ /(\d+)/
  codepage = $1.to_i
  codepages = (1251..1252)
 
  if codepages.include?(codepage)
    Cucumber::CODEPAGE = "cp#{codepage}"
  
    require 'iconv'
    module Kernel
      alias cucumber_print print
      def print(*a)
        begin
          cucumber_print(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a))
        rescue Iconv::IllegalSequence
          cucumber_print(*a)
        end
      end
 
      alias cucumber_puts puts
      def puts(*a)
        begin
          cucumber_puts(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a))
        rescue Iconv::IllegalSequence
          cucumber_puts(*a)
        end
      end
    end
  end
end