Handle foreign character web input

Chris Angelico rosuav at gmail.com
Fri Jun 28 16:33:32 EDT 2019


On Sat, Jun 29, 2019 at 6:31 AM Tobiah <toby at tobiah.org> wrote:
>
> A guy comes in and enters his last name as RÖnngren.
>
> So what did the browser really give me; is it encoded
> in some way, like latin-1?  Does it depend on whether
> the name was cut and pasted from a Word doc. etc?
> Should I handle these internally as unicode?  Right
> now my database tables are latin-1 and things seem
> to usually work, but not always.

Definitely handle them as Unicode. You'll receive them in some
encoding, probably UTF-8, and it depends on the browser. Ideally, your
back-end library (eg Flask) will deal with that for you.

> Also, what do people do when searching for a record.
> Is there some way to get 'Ronngren' to match the other
> possible foreign spellings?

Ehh....... probably not. That's a human problem, not a programming
one. Best of luck.

ChrisA



More information about the Python-list mailing list