]> git.ipfire.org Git - thirdparty/asterisk.git/commit
utf8.c: Add UTF-8 validation and utility functions
authorSean Bright <sean.bright@gmail.com>
Mon, 13 Jul 2020 20:06:14 +0000 (16:06 -0400)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Mon, 27 Jul 2020 22:36:23 +0000 (17:36 -0500)
commite9e441c39904a7d186399f88358d997cccb4c83b
tree3ad18220f4d69a45324fd2a236e481669b2b0ddb
parent15a3318f1f3fb72669b5659d12948fe3a01dd21b
utf8.c: Add UTF-8 validation and utility functions

There are various places in Asterisk - specifically in regards to
database integration - where having some kind of UTF-8 validation would
be beneficial. This patch adds:

* Functions to validate that a given string contains only valid UTF-8
  sequences.

* A function to copy a string (similar to ast_copy_string) stopping when
  an invalid UTF-8 sequence is encountered.

* A UTF-8 validator that allows for progressive validation.

All of this is based on the excellent UTF-8 decoder by Björn Höhrmann.
More information is available here:

    https://bjoern.hoehrmann.de/utf-8/decoder/dfa/

The API was written in such a way that should allow us to replace the
implementation later should we determine that we need something more
comprehensive.

Change-Id: I3555d787a79e7c780a7800cd26e0b5056368abf9
include/asterisk/utf8.h [new file with mode: 0644]
main/asterisk.c
main/utf8.c [new file with mode: 0644]