lugatuic / lug.cs.uic.edu-2018

https://lug.cs.uic.edu/
6 stars 2 forks source link

Unicode Support #52

Open BluuArc opened 5 years ago

BluuArc commented 5 years ago

image

Some characters look weird on some devices

BluuArc commented 5 years ago

The text in the image was originally Mathew (매튜) Kim

Benbigmac commented 5 years ago

looks like it's somewhere in the python code the issue front end displays it normally

BluuArc commented 5 years ago

Can confirm that it seems that it might by something on Python's side.

This is the response from the endpoint for that entry.

  {
    "description": "", 
    "github": "", 
    "graduating_semester": "", 
    "image": "", 
    "join_date": "", 
    "name": "Mathew (\u00eb\u00a7\u00a4\u00ed\u0160\u0153) Kim", 
    "personal_site": "", 
    "position": "Secretary", 
    "slack": "", 
    "special_ability": "", 
    "term_end": "SPRING_2017", 
    "term_start": "SUMMER_2016"
  }

Decoding the unicode in the name field becomes Mathew (매튜) Kim.

On the other hand, changing the name manually to Mathew (매튜) Kim on the frontend via a simple "Inspect Element" edit results in what we expected.

image

jakeraffe commented 5 years ago

Cant you simply declare the encoding in the python header? #-*- encoding: utf-8 -*-

Or maybe this can be solved by using configuration handling to force utf-8:

JSON_AS_ASCII=false

From the Flask documentation:

By default Flask serialize object to ascii-encoded JSON. If this is set to False Flask will not encode to ASCII and output strings as-is and return unicode strings. jsonify will automatically encode it in utf-8 then for transport for instance.

http://flask.pocoo.org/docs/0.12/config/