On 7 October 2011 12:51, Anurag Chourasia <[email protected]> wrote:
> Hi Graham,
>
> Is this correct about mod_wsgi?

Yes.

> "mod_wsgi was given the number of characters, not bytes"
>
> We use mod_wsgi but never hit this missing characters problem.

But are you using non latin-1 characters in Unicode strings? If you
are dealing only with english and european countries which uses
encodings where each character fits in one byte then you may not have
an issue.

BTW, email sent back to mod_wsgi mailing list.

Graham

> Regards,
> Anurag
>
> ---------- Forwarded message ----------
> From: Jason Garber <[email protected]>
> Date: Fri, Oct 7, 2011 at 7:17 AM
> Subject: Re: [modwsgi] Codding UTF-8
> To: [email protected]
>
>
> Hi Manuel,
> It seems that you would be really helped by learning more about
> unicode and utf-8.  I think this is a great introduction to it.
> http://www.joelonsoftware.com/articles/Unicode.html
> Remember, in UTF-8 encoding, most non-english characters will take 2
> or more bytes to represent during transport or storage.  This is why
> your last character was missing, because mod_wsgi was given the number
> of characters, not bytes... Since you only had one multi-byte
> character (in UTF-8), only one went missing.
> Suggest you try a WSGI framework like Bottle, Flask, AppStruct, etc...
> which insulates you from many of these arcane details.
> Take care,
> JG
>
> On Thu, Oct 6, 2011 at 5:29 PM, Manuel Antonio Mora Sandoval
> <[email protected]> wrote:
>>
>> Yes, thank you, Excuse me fot this dumb question, I don't know what happen.
>> Thank you very much.
>>
>> 2011/10/6 Deron Meranda <[email protected]>
>>>
>>> On Thu, Oct 6, 2011 at 11:33 AM, Manuel Antonio Mora Sandoval
>>> <[email protected]> wrote:
>>> >     output = 'Prueba con Ñ1'
>>> >     response_headers = [('Content-type', 'text/plain; charset=utf-8'),
>>> >                         ('Content-Length', str(len(output)))]
>>> >     start_response(status, response_headers)
>>> >     return [output.encode('utf-8')]
>>>
>>>
>>> The HTTP Content-Length specifies size in units of bytes.
>>>
>>> However the python len(output) returns the value in number of characters.
>>>
>>> Try setting content length to len(output.encode('utf-8'))
>>>
>>> --
>>> Deron Meranda
>>> http://deron.meranda.us/
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "modwsgi" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group at 
>>> http://groups.google.com/group/modwsgi?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "modwsgi" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to 
>> [email protected].
>> For more options, visit this group at 
>> http://groups.google.com/group/modwsgi?hl=en.
>
> --
> You received this message because you are subscribed to the Google
> Groups "modwsgi" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to