Module: Ropencc
- Defined in:
- lib/ropencc.rb,
lib/ropencc/version.rb
Defined Under Namespace
Constant Summary collapse
- DICTS =
module LibC
{ :simp_to_trad => ['simp_to_trad_characters.ocd','simp_to_trad_phrases.ocd','simp_to_trad_variant.ocd'], :trad_to_simp => ['trad_to_simp_characters.ocd','trad_to_simp_phrases.ocd','trad_to_simp_variant.ocd'] }
- VERSION =
"0.0.4"
Class Method Summary collapse
Class Method Details
.conv(dicttype, str) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ropencc.rb', line 28 def conv(dicttype, str) od = LibOpenCC.opencc_open nil DICTS[dicttype.to_sym].each { |dict| LibOpenCC.opencc_dict_load(od, dict, 1) } ptr = LibOpenCC.opencc_convert_utf8(od, str, str.bytesize) out_str = ptr.read_string LibC.free ptr LibOpenCC.opencc_close od out_str.force_encoding("UTF-8") if out_str.respond_to?(:force_encoding) out_str end |