I am working on a small flash application in which I want to return strings containing umlauts (in general, German special characters, for example 'ß'). Since the default JSONEncoderin flask has ensure_ascii=True, this will always convert my string
Hauptstraße 213
:
Hauptstra\u00dfe 213
My first approach was to simply create a very simple custom JSONEncoder
class NonAsciiJSONEncoder(json.JSONEncoder):
def __init__(self, **kwargs):
super(NonAsciiJSONEncoder, self).__init__(kwargs)
self.ensure_ascii = False
If I use this by setting
app.json_encoder = NonAsciiJSONEncoder
my return jsonify(...)will actually return a string containing 'ß'.
However, since this ensure_asciiis the default Encoder attribute, I thought it would be better to change it by setting it toFalse
app.json_encoder.ensure_ascii = False
False, . - 'ß', \u00df.
, , Encoder, False?