server encoding

Martin Atkins mart at degeneration.co.uk
Tue Feb 28 19:11:48 UTC 2006


Kevin Williams wrote:
> So if .NET defaults to UTF8 encoding on everything, the server
> messages would be OK because ASCII characters encoded as UTF8 don't
> change, correct? I'm trying to write a *server*, not a client, so I
> just want to make sure that I do the right things internally.
> 
> Thanks for the help! I can't wait to get this running.
> 

The correct data type for storing data submitted from memcached clients
is byte[], not string. If you try to encode each byte as a Unicode
codepoint in UTF-8 you'll end up with bloaty data every time a client
wants to store a byte greater than 127.

Different client libraries send different things, so all you can do is
store it as raw bytes and serve it back exactly as it came, octet for
octet; it's up to the client to know what format the data is in.



More information about the memcached mailing list