Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/helper/strenc.rb
Constant Summary collapse
- @@encs =
%w(ascii utf-8 gb18030 gbk gb2312 cp936 big5)
Instance Attribute Summary collapse
-
#former_enc ⇒ Object
readonly
Returns the value of attribute former_enc.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#former_enc ⇒ Object (readonly)
Returns the value of attribute former_enc.
26 27 28 |
# File 'lib/helper/strenc.rb', line 26 def former_enc @former_enc end |
Class Method Details
.encs ⇒ Object
8 |
# File 'lib/helper/strenc.rb', line 8 def encs; @@encs; end |
.encs=(arr) ⇒ Object
9 |
# File 'lib/helper/strenc.rb', line 9 def encs=(arr); @@encs = arr; end |
Instance Method Details
#enc!(encoding) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/helper/strenc.rb', line 28 def enc!(encoding) if respond_to? :force_encoding force_encoding encoding if valid_encoding? @former_enc = encoding return self end end @@encs.each do |c| begin if send :try_convert, encoding, c @former_enc = c break end rescue end end self end |