Class: String

### Home Classes Methods

### In Files

- lib/blankslate.rb
- lib/builder/xchar.rb

### Parent

Object

### Methods

- #_blankslate_as_name
- #to_xs

### Files

- CHANGES
- MIT-LICENSE
- Rakefile
- builder-1.2.4.rdoc
- builder-2.0.0.rdoc
- builder-2.1.1.rdoc

### Class/Module Index

Quicksearch

- Builder
- Builder::BlankSlate
- Builder::IllegalBlockError
- Builder::XmlBase
- Builder::XmlEvents
- Builder::XmlMarkup
- BlankSlate
- Fixnum
- Kernel
- Module
- Object
- String
- Symbol

No matching classes.

# String

    Permission is granted for use, copying, modification, distribution,
    and distribution of modified versions of this work as long as the
    above copyright notice is included.

++

Enhance the String class with a XML escaped character version of to_s.

### Public Instance Methods

_blankslate_as_name() click to toggle source

    # File lib/blankslate.rb, line 13
    def _blankslate_as_name
      to_sym
    end

to_xs(escape=true) click to toggle source

XML escaped version of to_s. When `escape` is set to false the CP1252 fix is still applied but utf-8 characters are not converted to character entities.

    # File lib/builder/xchar.rb, line 191
    def to_xs(escape=true)
      unpack('U*').map {|n| n.xchr(escape)}.join # ASCII, UTF-8
    rescue
      unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.