Given unsigned char *str, a UTF-8 encoded string, is it legal to write the first byte (not character) with fputc((char)(*str), file);
Given unsigned char *str , a UTF-8 encoded string, is it legal to write
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Remove the cast to
char.fputctakes the character to write as anintargument whose value is expected to be in the range ofunsigned char, notchar. Assuming(unsigned char)(char)acts as the identity operator onunsigned charvalues, there’s no error in your code, but it’s not guaranteed to especially for oddball systems without twos complement.