better error handling for failed string conversions
Fix wchar cursor movement.