TLDR Web Dev · MISCELLANEOUS
THE BEST – BUT NOT GOOD – WAY TO LIMIT STRING LENGTH
Summary from the TLDR Web Dev newsletter
This deep dive into limiting string length shows the inconsistencies and potential issues arising from different character encoding methods. It goes over various encoding schemes like UTF-8, UTF-16, Unicode code points, and grapheme clusters, showing how their differing length calculations can lead to bugs and poor user experiences across different layers of an application. Devs need to be intentional and consistent with their chosen counting method and they should understand how the programming language they use handles strings. Counting by normalized Unicode code points is generally the best approach.