# Custom encoding in qgis-web-client wsgi search

Firstly I would like to note that my qgis-webclient and the wsgi searching are all working correctly as they should. After creating afew datatables for test purposes the url: http://localhost:1234/wsgi/search.wsgi?query=&searchtables=&query=11&cb=stcCallback1002 returned the correct values. Now my problem is that the encoding used in the wsgi script is using an python file somedisk\somepath\OSGeo4W\apps\Python27\Lib\json\encoding.py. With this file the text returned is encoded in UTF-8.

Now my question is how can I change this encoding to something different, in my case WIN1250 (ISO/IEC 8859-2).

My question was not really related to this stack-exchange but I'll answer it anyways. So the solution lies in reading the definition for json.dumps(). This method is used to encode your result string by default with UTF-8. If you want to change that, you should look for your encoding in the following folder: path\to\python\PythonX\Lib\encodings.

Here you will find many encoding .py files. Choose the one you want and remember its name -> name.py. Now you should open your search.wsgi script and go to line 136 (if you didn't change the file) and look for the following line:

resultString = '{"restults:": '+json.dumps(rowData)+'}'


The function json.dumps also accepts other parametres as stated in this link. So if you change this line to:

resultString = '{"restults:": '+json.dumps(rowData, encoding="name")+'}'


Then your restultString should be properly encoded (in my exact case the "name" should be "cp1250") and the results will display correctly without the internal server error.