This may be because you are using signed characters. And during bitshifting the indexes may be changed undesirably due to MSB (sign bit). And characters with undesired indexes do not show the accurate result .
Try using unsigned char instead of simply using char.