On Thu, Oct 29, 2009 at 5:04 PM, Russell <
miste...@googlemail.com> wrote:
>
> Hi,
> This is probably not a mochiweb thing, more a web thing but: I have a
> module that creates a tuple. This tuple is then converted to a binary
> using term_to_binary(Tuple). I then return this binary to the client
> ( {200, [{"Content-Type", "text/plain"}], Term}; ).
>
> On the client,when I look at the returned data the first char has
> become 65533 (unicode Character 'REPLACEMENT CHARACTER' (U+FFFD)) not
> the char 131 that I would expect to see as the first character.
The problem is in your client, not in the server. Although
"text/plain" is a weird content-type for binary data and you should
probably fix that, it sounds like your client is parsing the body as a
UTF-8 string instead of leaving it as binary. Obviously you're not
going to see any values outside of [0-255] if your client is properly
reading the body as binary octets.