Usando buffer[i] come carattere !

char c;

c=buffer[i];
...

e il codice ASCII ...