This package provides a pure Elm implementation of the Unicode Normalization algorithm.
String.prototype.normalize()?Yes, and you should probably use that instead! This implementation certainly will be slower than the browser's well-optimized solution.
I created this package because I needed to normalize strings deep inside some complicated business logic. Calling out to the JavaScript implementation through a port was possible, but really not ideal. I would have to turn my business logic into a port module, add messages interrupting the normal control flow, a lot of the code couldn't be pure Elm anymore, et cetera, et cetera, et cetera. If you find yourself in a similar situation, this package is for you!
The test suite is generated from the suite provided by Unicode. There are quite a lot of tests, so it takes a while to run, but I am highly confident that the implementation is correct. Try make test to run the tests for yourself.
The current version (1.0.0) is a very naive implementation focusing entirely on correctness over performance. The code operates directly on a list of code points (List Int internally). However, it is definitely possible to do better, even in pure Elm! Here are some planned improvements:
Array Int.These improvements will be implemented in versions 1.0.1 and beyond.