SQLite Forum

Why is utf8 IN char* but utf8 OUT is unsigned char*
Login
In the bytes that are stored there is no difference between "char" and "unsigned char".  There is no "conversion" that takes place when you tell the compiler that something is "signed char" vs "unsigned char".  All you are doing is telling the compiler to emit different instructions.

If a is a "signed char" then the statement a > 0xc0 is *always* false unless one assumes that 0xc0 is also a signed char, in which case the meaning is entirely opposite from what one expects.

So telling the compiler that a "char" is signed or unsigned is merely a convention to that you can (a) write code that does what it appears to be saying and (b) have the compiler emit the correct instruction to "do what you mean".  The signed/unsigned has absolutely zero "conversion" effect of the data, merely how the compiler implements your manipulations.

That is, it merely distinguishes whether the same data is bytes from 0 to 255, or bytes from -128 to 127 in two-s complement.  The value (bit pattern) of the byte does not change.