Updated to set encoding from system (untested)