v.23.8New Feature

Add startsWithUTF8 and endsWithUTF8 functions

Add new function startsWithUTF8 and endsWithUTF8. #52555 (李扬).
Added new string functions startsWithUTF8 and endsWithUTF8 for accurate prefix and suffix checks with UTF-8 encoded strings.

Why it matters

These functions solve the problem of correctly determining if a UTF-8 encoded string starts or ends with a specified substring, handling multi-byte characters properly. This ensures reliable string matching in internationalized text processing.

How to use it

Use the functions in SQL queries to check prefixes or suffixes of UTF-8 strings as follows:

SELECT startsWithUTF8(string, prefix) FROM table;
SELECT endsWithUTF8(string, suffix) FROM table;

They return a boolean indicating if the string starts or ends with the given UTF-8 substring.