Method: WizRtf::RtfIO#txt

Defined in:
lib/wiz_rtf/rtf_io.rb

#txt(str) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/wiz_rtf/rtf_io.rb', line 23

def txt(str)
  str = str.to_s
  str = str.gsub("{", "\\{").gsub("}", "\\}").gsub("\\", "\\\\")
  str = str.encode("UTF-16LE", :undef=>:replace).each_codepoint.map {|n| n < 128 ? n.chr : "\\u#{n}\\'3f"}.join('')
  @io.write ' '
  @io.write str
end