Skip to content
shaohef edited this page Jan 13, 2014 · 1 revision
support create a resource with unicode name(done)

One principle:
We should audit the code in order to properly handle unicode throughout.
This means always calling var.decode('utf-8') on incoming text and
var.encode('utf-8') on outgoing text.

For incoming text:
The json body from the UI client is unicode, is decoded by incoming
filter (parse_request).
The URL from the UI client is str, need decode.
The text form libvirt is str, need decode.

For outgoing text:
Outgoing text to libvirt, such as xml or VM name should be encode.
Outgoing text to UI should be encode by template render.

At last we should achieve:
All text strings, everywhere should be of type unicode, not str.
If you're handling text, and your variable is a str, it's a bug!