Should a buffer of bytes be signed char or unsigned char or simply a char buffer?
Any differences between C and C++?
Thanks.
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.
A minor difference in how the language treats it. A huge difference in how convention treats it.
char= ASCII (or UTF-8, but the signedness gets in the way there) textual dataunsigned char= bytesigned char= rarely usedAnd there is code that relies on such a distinction. Just a week or two ago I encountered a bug where JPEG data was getting corrupted because it was being passed to the
char*version of our Base64 encode function — which “helpfully” replaced all the invalid UTF-8 in the “string”. Changing toBYTEakaunsigned charwas all it took to fix it.