Enhance the Fixnum class with a XML escaped character conversion.
Methods
Constants
| XChar | = | Builder::XChar if ! defined?(XChar) |
Public Instance methods
XML escaped version of chr. When escape is set to false the CP1252 fix is still applied but utf-8 characters are not converted to character entities.
[ show source ]
# File lib/builder/xchar.rb, line 171
171: def xchr(escape=true)
172: n = XChar::CP1252[self] || self
173: case n when *XChar::VALID
174: XChar::PREDEFINED[n] or
175: (n<128 ? n.chr : (escape ? "&##{n};" : [n].pack('U*')))
176: else
177: Builder::XChar::REPLACEMENT_CHAR
178: end
179: end