The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Email Subscription

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 717 other subscribers

The mojibake “creëer”

Posted by jpluimers on 2024/08/22

A while ago, I found the “creëer” mojibake in a Dutch page on the IKEA site.

They were not alone to make this mistake which is easily explained using [Wayback/Archive] ftfy:

>>> ftfy.fix_and_explain("creëer")
ExplainedText(text='creëer', explanation=[('encode', 'latin-1'), ('decode', 'utf-8')])

(you can run this on-line at [Wayback/Archive] Welcome to Python.org: interactive shell, see my post The things I didn’t notice during cancer survival: ftfy 6.0 and more versions got released during my recovery on how to do this)

So the text is easily fixed:

>>> s="creëer"
>>> s.encode('latin-1')
b'cre\xc3\xaber'
>>> s.encode('latin-1').decode('utf-8')
'creëer'

Encoding isn’t hard, you just have to be aware of storage and various transcoding steps taking place in your development and operation stacks, in this case mixing Latin-1 (ISO/IEC 8859-1) and UTF-8.

Related

--jeroen


https://gist.github.com/jpluimers/19777107b1cfec4cdc972eb813520719

Leave a Comment