Closed hyzeer closed 4 years ago
Hi @hyzeer,
thanks for reporting this issue - I never tried to send non ASCII chars through JSON, so you're totally right! :)
It actually easy to fix by
chunk_len = len(s.encode('utf-8'))
await resp.send('{:x}\r\n'.format(chunk_len))
The question here is - do you guys always using utf8
as default encoding?
In Russia we do use utf8
as default, so I wonder do we need to make encoding configurable or we can just hardcode it - in order to save bytecode / RAM.
Hi @belyalov , thanks for your reply. Yes, most of us do using utf-8 as default encoding anytime. :)
Could you release new firmware after fixed? I can do it, but I not cross compile environment. Thanks!
Fix just landed and new firmware is ready.
Enjoy!
Thanks! :)
Hi , thank you very much for your wonderful framework , but I regret to find an error in processing NON-ASCII characters by using the framework .
the above codes in server.py at line 337-340 , "len(chunk)" refer to the numbers of the character variable "chunk" , not the bytes length . It's OK with the return of the function "len( )" , when the character variable is ASCII type , but for the NON-ASCII type , such as a Chinese character , the character number is 1 in function "len( )" , and the length is 3 bytes . So , this function will cause a loss in transmission .