Class: RubyXL::Text
- Inherits:
-
OOXMLObject
- Object
- OOXMLObject
- RubyXL::Text
- Defined in:
- lib/rubyXL/objects/text.rb
Overview
Constant Summary collapse
- INVALID_XML10_CHARS =
www.w3.org/TR/REC-xml/#NT-Char: Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
/([^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD\u10000-\u10FFFF])/
- ESCAPED_UNICODE =
/_x([0-9A-F]{4})_/
Instance Method Summary collapse
Methods included from OOXMLObjectInstanceMethods
#==, included, #index_in_collection, #initialize, #write_xml
Instance Method Details
#before_write_xml ⇒ Object
20 21 22 23 24 |
# File 'lib/rubyXL/objects/text.rb', line 20 def before_write_xml preserve_whitespace self.value.gsub!(INVALID_XML10_CHARS) { |c| "_x%04x_" % c.ord } true end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/rubyXL/objects/text.rb', line 26 def to_s value.to_s.gsub(ESCAPED_UNICODE) { |m| $1.hex.chr(Encoding::UTF_8) } end |