Removed charSize input, replaced with encoding to deal with Unicode