Handling over-long UTF-8 sequences
Posted
by Grant McLean
on Stack Overflow
See other posts from Stack Overflow
or by Grant McLean
Published on 2010-04-30T10:54:08Z
Indexed on
2010/04/30
10:57 UTC
Read the original article
Hit count: 354
I've just been reworking my Encoding::FixLatin Perl module to handle over-long utf8 byte sequences and convert them to the shortest normal form.
My question is quite simply "is this a bad idea"?
A number of sources (including this RFC) suggest that any over-long utf8 should be treated as an error and rejected. They caution against "naive implementations" and leave me with the impression that these things are inherently unsafe.
Since the whole purpose of my module is to clean up messy data files with mixed encodings and convert them to nice clean utf8, this seems like just one more thing I can clean up so the application layer doesn't have to deal with it. My code does not concern itself with any semantic meaning the resulting characters might have, it simply converts them into a normalised form.
Am I missing something. Is there a hidden danger I haven't considered?
© Stack Overflow or respective owner