use -1 instead of 0xFF as invalid char value. It was very stupid not to do this