File: string.rb

package info (click to toggle)
libhtmlentities-ruby 4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 136 kB
  • ctags: 294
  • sloc: ruby: 2,172; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 645 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'htmlentities'

#
# This file extends the String class with methods to allow encoding and decoding of
# HTML/XML entities from/to their corresponding UTF-8 codepoints.
#
class String

  #
  # Decode XML and HTML 4.01 entities in a string into their UTF-8
  # equivalents.
  #
  def decode_entities
    return HTMLEntities.decode_entities(self)
  end
  
  #
  # Encode codepoints in a string into their corresponding entities. See
  # the documentation of HTMLEntities.encode_entities for a list of possible
  # instructions.
  #
  def encode_entities(*instructions)
    return HTMLEntities.encode_entities(self, *instructions)
  end

end