lib/writeexcel/format.rb in writeexcel-0.5.0 vs lib/writeexcel/format.rb in writeexcel-0.6.0

- old
+ new

@@ -21,10 +21,11 @@ require 'writeexcel/colors' module Writeexcel class Format < Colors + NonAscii = /[^!"#\$%&'\(\)\*\+,\-\.\/\:\;<=>\?@0-9A-Za-z_\[\\\]\{\}^` ~\0\n]/ ############################################################################### # # initialize(xf_index=0, properties = {}) # xf_index : @@ -367,15 +368,23 @@ bFamily = @font_family bCharSet = @font_charset rgch = @font encoding = @font_encoding - rgch = convert_to_ascii_if_ascii(rgch) + ruby_19 { rgch = convert_to_ascii_if_ascii(rgch) } # Handle utf8 strings - if rgch.encoding == Encoding::UTF_8 - rgch = utf8_to_16be(rgch) - encoding = 1 + ruby_18 do + if rgch =~ NonAscii + rgch = utf8_to_16be(rgch) + encoding = 1 + end + end + ruby_19 do + if rgch.encoding == Encoding::UTF_8 + rgch = utf8_to_16be(rgch) + encoding = 1 + end end cch = rgch.bytesize # # Handle Unicode font names.