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

Revision 18425, 0.6 KB (checked in by davidb, 11 years ago)

Video extension to Greenstone

Line 
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 browser.