Sha256: 74e06aba967ceb382a831034a1a7a54c02923e3d71fb5d45298ad61e51329d60
Contents?: true
Size: 834 Bytes
Versions: 11
Compression:
Stored size: 834 Bytes
Contents
require "nkf" module SmallCage # In _dir.smc or other *.smc, set charset like this: # # charset: Shift_JIS # class NkfFilter def initialize(opts) end def after_rendering_filter(obj, str) charset = "" if obj["charset"] charset = obj["charset"] else obj["dirs"].reverse.each do |dir| if dir["charset"] charset = dir["charset"] break end end end opt = "" if charset =~ /^euc-jp$/i opt = "-Wem0" elsif charset =~ /^iso-2022-jp$/i opt = "-Wjm0" elsif charset =~ /^shift_jis$/i opt = "-Wsm0" else STDERR.puts "Unknown charset: #{charset}" unless charset.empty? return str end return NKF.nkf(opt, str) end end end
Version data entries
11 entries across 11 versions & 2 rubygems