Ringo Blancke
Ringo Blancke

Reputation: 2444

UTF-8 decoding error in Python

I'm trying to do this in Python: 'Fi\xc3\xb1a'.decode('utf-8')

I expect the result to be Fiña. But the result is actually: u'Fi\xf1a'

No idea what is going on, some help on this would be much appreciated.

Thanks!

Upvotes: 1

Views: 317

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308111

You're getting the correct result, the Unicode codepoint for ñ is U+00f1. It's just that Python won't display the Unicode character directly. Try it in a print statement and see what you get.

Upvotes: 5

Related Questions