2. 用ipArray.uniq!() 来删除重复的ip,如有2个相同ip,运行方法,后剩下了1个
3. 然后count = ipArray.size
在命令行安装unicode包:gem install unicode
在程序里:
require 'unicode'
$KCODE = 'UTF-8' # only used when encoding is not specified.
u = "\352\260\200\353\202\230\353\213\244".to_u
u.length #=>3
u.to_a #=>[44032, 45208, 45796], array of codepoint
u.inspect #=><U+AC00><U+B098><U+B2E4>
u.to_s #=>"\352\260\200\353\202\230\353\213\244"
u.encoding = "EUC-KR"
u.to_s #=>"\260\241\263\252\264\331"
u.to_s("UTF-8")#=>"\352\260\200\353\202\230\353\213\244"
u.length #=>3
u = "\260\241\263\252\264\331".to_u("EUC-KR")
u.inspect #=><U+AC00><U+B098><U+B2E4>