module Mingle::Chars
Constants
- SIMPLE_ESCAPE_STRS
- SIMPLE_ESCAPE_VALS
Public Instance Methods
ctl_char?( ch )
click to toggle source
# File lib/mingle.rb, line 528 def ctl_char?( ch ) ( 0x00 ... 0x20 ).include?( ch.ord ) end
external_form_of( val )
click to toggle source
# File lib/mingle.rb, line 541 def external_form_of( val ) res = RubyVersions.when_19x( '"' ) { |s| s.encode!( "binary" ) } val.each_byte do |b| case when Chars.ctl_char?( b ) if s = Chars.get_simple_escape( b ) res << s else res << sprintf( "\\u%04X", b ) end when b == ?".ord || b == ?\\.ord then res << "\\" << b else res << b end end RubyVersions.when_19x( res << '"' ) { |s| s.force_encoding( "utf-8" ) } end
get_simple_escape( ch )
click to toggle source
# File lib/mingle.rb, line 532 def get_simple_escape( ch ) if i = SIMPLE_ESCAPE_VALS.index( ch.chr ) SIMPLE_ESCAPE_STRS[ 2 * i, 2 ] else nil end end