source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/yaml/encoding.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 612 bytes
RevLine 
[18425]1#
2# Handle Unicode-to-Internal conversion
3#
4
5module YAML
6
7 #
8 # Escape the string, condensing common escapes
9 #
10 def YAML.escape( value, skip = "" )
11 value.gsub( /\\/, "\\\\\\" ).
12 gsub( /"/, "\\\"" ).
13 gsub( /([\x00-\x1f])/ ) do |x|
14 skip[x] || ESCAPES[ x.unpack("C")[0] ]
15 end
16 end
17
18 #
19 # Unescape the condenses escapes
20 #
21 def YAML.unescape( value )
22 value.gsub( /\\(?:([nevfbart\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/ ) { |x|
23 if $3
24 ["#$3".hex ].pack('U*')
25 elsif $2
26 [$2].pack( "H2" )
27 else
28 UNESCAPES[$1]
29 end
30 }
31 end
32
33end
Note: See TracBrowser for help on using the repository browser.