Efficient character buffer implementation