brianmario / fast_xs

excessively fast escaping
MIT License
28 stars 6 forks source link

to_xs has changed in builder 3 fast_xs should deal with it #1

Open SamSaffron opened 12 years ago

SamSaffron commented 12 years ago
class String
  # XML escaped version of to_s. When <tt>escape</tt> is set to false
  # the CP1252 fix is still applied but utf-8 characters are not
  # converted to character entities.
  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
end
SamSaffron commented 12 years ago

at the moment fast_xs blows up on an instruct! in rails 3.1

rubydog commented 12 years ago

Yes problem is little but annoying. Please fix it.