On 01/22/2014 07:09 PM, Mark Wu wrote:
The encoding option for json.dumps() is used to indicate the
charsets
of the passed in str. Currently, we use the encoding of iso-8859-1,
but actually we don't have any data encoded in iso-8859-1. It doesn't
cause any problem because the strings in the data passed are ascii chars
or unicode. If we pass a utf-8 str, it will canse an expected result.
canse?
So we could remove the option, and after that it can accept utf-8 str
too
because json.dumps use utf-8 as default encoding.
Signed-off-by: Mark Wu <wudxw(a)linux.vnet.ibm.com>
---
src/kimchi/template.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/kimchi/template.py b/src/kimchi/template.py
index 1f19c4a..f854657 100644
--- a/src/kimchi/template.py
+++ b/src/kimchi/template.py
@@ -84,9 +84,7 @@ def can_accept_html():
def render(resource, data):
if can_accept('application/json'):
cherrypy.response.headers['Content-Type'] =
'application/json;charset=utf-8'
- return json.dumps(data, indent=2,
- separators=(',', ':'),
- encoding='iso-8859-1')
+ return json.dumps(data, indent=2, separators=(',', ':'))
elif can_accept_html():
filename = config.get_template_path(resource)
try:
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center