Fixed the bug relating to encoding in ruby < 2