The extra char you see is the wide-char newline (0x000a
) that is kept at the end of the string you read with fgetws
and that you shift by 6 chars, resulting in 0x0010
. That doesn't seem to be a printable character and the terminal decides to print the character code as plain hex numbers.
Remove the trailing new-line before shifting or shift only printable characters.