Method: String#encoding

Defined in:
lib/audioinfo.rb

#encodingObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/audioinfo.rb', line 22

def encoding
cuenta=0
ascii=true
self.each_byte{|byte|
	if cuenta>0
		if (byte >> 6) != 0b10
			return "iso8859"
		else
			cuenta-=1
		end
	else
		next if(byte<128)
		ascii=false
		if (byte >> 5) == 0b110 
			cuenta=1
		elsif (byte >> 4) == 0b1110
			cuenta=2
		elsif (byte >> 3) == 0b11110
			cuenta=3
		else
			return "iso8859"
		end
	end
}
ascii ? "ascii":"utf8"
end