Use mbrtowc() function, it will help you to check the length of every character.