I have this ini file
[temp]
units = \u00b0 C
If I retrieve the value with ConfigParser, I get the following result
pi@pi-vm1:~ $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from configparser import ConfigParser
>>> parser = ConfigParser()
>>> parser.read('/home/pi/myapp/units.ini', encoding='utf-8')
['/home/pi/myapp/units.ini']
>>> items = parser.items('temp')
>>> print(items[0])
('units', '\\u00b0 C')
This is passed as an API response, and the end result is that the browser renders \u00b0 on the page.
If I put into my code directly:
units = "\u00b0C"
Then this works fine, and is rendered as a degree symbol
So, basically these two lines render a different output.
units = unitsConfig['units']
units = "\u00b0C"
How can I get the config file method to return the same string as if I specified it directly in the code?