pickup automatically the correct char encoding based on the first byte of the buffer