Fixed string encoding value.
Added castings to fix compiler warnings.