jemc / crystal-pegmatite

A high-performance Parsing Expression Grammar (PEG) library for the Crystal language. :gem: :capital_abcd:
Mozilla Public License 2.0
28 stars 5 forks source link

Fix a bug in UTF-8 decoding of 4-byte codepoints. #11

Closed jemc closed 2 years ago

jemc commented 2 years ago

Prior to this bug fix, decoding a UTF-8 codepoint that was encoded as 4 bytes would result in an incorrect value, and could sometimes result in an arithmetic overflow exception.

This was the result of a copy-paste typo, using the wrong variable name.

This commit fixes that issue and also adds to the test cases so that the 2-byte, 3-byte, and 4-byte paths are exercised during tests.