Module: Ykutils::NKFUTIL

Included in:
SpecFileOp
Defined in:
lib/ykutils/nkfutil.rb,
lib/ykutils/nkfutil19.rb,
lib/ykutils/nkfutil20.rb

Defined Under Namespace

Classes: Assoc

Constant Summary collapse

CODE_TO_NAME =
Hash.new("ASCII")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assoc_equal(target, key) ⇒ Object



112
113
114
# File 'lib/ykutils/nkfutil.rb', line 112

def self.assoc_equal(target, key)
  target == key || target == Assoc.get(key)
end

.auto_config_from_inner(dest_encoding, misc_option = nil) ⇒ Object



124
125
126
# File 'lib/ykutils/nkfutil.rb', line 124

def self.auto_config_from_inner(dest_encoding, misc_option = nil)
  Assoc.auto_config_to_inner(dest_encoding, misc_option)
end

.auto_config_to_inner(str, misc_option = nil) ⇒ Object



120
121
122
# File 'lib/ykutils/nkfutil.rb', line 120

def self.auto_config_to_inner(str, misc_option = nil)
  Assoc.auto_config_to_inner(str, misc_option)
end

.config(src_encoding, dest_encoding, misc_option = nil) ⇒ Object



116
117
118
# File 'lib/ykutils/nkfutil.rb', line 116

def self.config(src_encoding, dest_encoding, misc_option = nil)
  Assoc.config(src_encoding, dest_encoding, misc_option)
end

.convert(str) ⇒ Object



104
105
106
107
108
109
110
# File 'lib/ykutils/nkfutil.rb', line 104

def self.convert(str)
  if str.nil?
    ""
  else
    Assoc.convert(str)
  end
end

.get(key) ⇒ Object



100
101
102
# File 'lib/ykutils/nkfutil.rb', line 100

def self.get(key)
  Assoc.get(key)
end

.guess_encoding(str) ⇒ Object



14
15
16
# File 'lib/ykutils/nkfutil.rb', line 14

def self.guess_encoding(str)
  CODE_TO_NAME[NKF.guess(str)]
end

.set(key, value) ⇒ Object



96
97
98
# File 'lib/ykutils/nkfutil.rb', line 96

def self.set(key, value)
  Assoc.set(key, value)
end

Instance Method Details

#nkf_utf8_file(infname, outfname) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/ykutils/nkfutil.rb', line 136

def nkf_utf8_file(infname, outfname)
  File.open(outfname) do |outf|
    File.open(infname) do |file|
      while (line = file.gets)
        line.chomp!
        oline = NKF.nkf("-w -m0", line)
        outf.printf("%s\n", oline)
      end
    end
  end
end

#puts_sj(line) ⇒ Object



128
129
130
# File 'lib/ykutils/nkfutil.rb', line 128

def puts_sj(line)
  puts NKF.nkf("-Ws -m0", line)
end

#puts_u(line) ⇒ Object



132
133
134
# File 'lib/ykutils/nkfutil.rb', line 132

def puts_u(line)
  puts NKF.nkf("-Sw -m0", line)
end