Class: Fixnum
Overview
Enhance the Fixnum class with a XML escaped character conversion.
Constant Summary collapse
- XChar =
JsonBuilder::XChar
Instance Method Summary collapse
-
#xchr(escape = true) ⇒ Object
XML escaped version of chr.
Instance Method Details
#xchr(escape = true) ⇒ Object
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.
81 82 83 84 85 86 87 88 |
# File 'lib/json_builder/xchar.rb', line 81 def xchr(escape=true) n = XChar::CP1252[self] || self case n when *XChar::VALID XChar::PREDEFINED[n] or (n<128 ? n.chr : (escape ? "&##{n};" : [n].pack('U*'))) else '*' end end |