Class: Moc::Protocol::String
- Inherits:
-
String
- Object
- String
- Moc::Protocol::String
- Extended by:
- Type
- Defined in:
- lib/moc/protocol/string.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Type
Class Method Details
.read(io) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/moc/protocol/string.rb', line 16 def self.read (io) length = Integer.read(io) string = io.read(length) %w[UTF-8 ISO-8859-1].each {|encoding| if string.force_encoding(encoding).valid_encoding? return new(string) end } new(string.force_encoding('BINARY')) end |