Module: Deplate::Encoding

Defined in:
lib/deplate/encoding.rb

Overview

require ”

Class Method Summary collapse

Class Method Details

.canonic_enc_name(enc, table = @encodings) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/deplate/encoding.rb', line 33

def canonic_enc_name(enc, table=@encodings)
    case enc.downcase
    when 'latin-1', 'latin1', 'l1', 'isolat1', 'iso-8859-1'
        cen = 'latin1'
    when 'latin-9', 'latin9', 'l9', 'isolat9', 'iso-8859-15'
        cen = 'latin9'
    when 'gb2312', 'gbk'
        cen = 'gb2312'
    when 'koi8-r'
        cen = 'koi8-r'
    when 'utf8', 'utf-8'
        cen = 'utf-8'
    else
        log(['Unsupported encoding', enc], :anyway)
        cen = enc
    end
    return (table && table[cen]) || cen
end

.ruby_enc_name(enc) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/deplate/encoding.rb', line 14

def ruby_enc_name(enc)
    case enc.downcase
    when 'latin-1', 'latin1', 'l1', 'isolat1', 'iso-8859-1'
        cen = 'iso-8859-1'
    when 'latin-9', 'latin9', 'l9', 'isolat9', 'iso-8859-15'
        cen = 'iso-8859-15'
    when 'gb2312', 'gbk'
        cen = 'gb2312'
    when 'koi8-r'
        cen = 'koi8-r'
    when 'utf8', 'utf-8'
        cen = 'utf-8'
    else
        log(['Unsupported ruby encoding', enc], :anyway)
        cen = enc
    end
    return cen
end