Method: Rex::Text.unicode_filter_encode
- Defined in:
- lib/rex/text.rb
.unicode_filter_encode(str) ⇒ Object
A custom unicode filter for dealing with multi-byte strings on a 8-bit console Punycode would have been more “standard”, but it requires valid Unicode chars
1711 1712 1713 1714 1715 1716 1717 |
# File 'lib/rex/text.rb', line 1711 def self.unicode_filter_encode(str) if (str.to_s.unpack("C*") & ( LowAscii + HighAscii + "\x7f" ).unpack("C*")).length > 0 str = "$U$" + str.unpack("C*").select{|c| c < 0x7f and c > 0x1f and c != 0x2d}.pack("C*") + "-0x" + str.unpack("H*")[0] else str end end |