How to test an application for correct encoding (e.g. UTF-8)

前端 未结 5 989
孤独总比滥情好
孤独总比滥情好 2021-02-05 09:16

Encoding issues are among the one topic that have bitten me most often during development. Every platform insists on its own encoding, most likely some non-UTF-8 defaults are in

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 10:01

    The real troublemaker with character encoding is quite often that there are multiple encoding-related bugs and that some incorrect behavior has been introduced because of other bugs. I have no count of how many times I have seen this happen.

    The goal, as always, is to handle it correctly in every single place. So most of the time simple unit tests can do the trick, it doesn't even have to be very complex character sets. I find all out bugs just by testing on our national character "ø", because it maps differently in UTF-8 and most of the other character sets.

    The aggregate works fine when all the pieces do it correctly. I know this sounds trivial, but when it comes to character set issues it's always worked for me ;)

提交回复
热议问题