module StringTools::CharDet
Constants
- CP1251_COMPATIBLE_ENCODINGS
Public Instance Methods
detect_encoding(str)
click to toggle source
shorthand
# File lib/string_tools.rb, line 24 def detect_encoding(str) str.detect_encoding end
to_cp1251(str)
click to toggle source
# File lib/string_tools.rb, line 33 def to_cp1251(str) str.to_cp1251 end
to_utf8(str)
click to toggle source
привести строку к utf8
# File lib/string_tools.rb, line 29 def to_utf8(str) str.to_utf8 end
valid_utf8?(string)
click to toggle source
Возвращает true если строка содержит допустимую последовательность байтов для кодировки utf8 и false в обратном случае см. en.wikipedia.org/wiki/UTF-8
# File lib/string_tools.rb, line 19 def valid_utf8?(string) string.respond_to?(:is_utf8?) && string.is_utf8? end