Actually you would have to convert the strings to UCS-4. UTF-16 is a variable-length encoding. An actual "unicode character" is (at this present moment in time, though perhaps not tomorrow) 4 bytes (64-bits).
--- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-----Original Message----- >From: sqlite-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Warren Young >Sent: Friday, 12 April, 2019 09:45 >To: SQLite mailing list >Subject: Re: [sqlite] Help with sqlite3_value_text > >On Apr 12, 2019, at 8:51 AM, x <tam118...@hotmail.com> wrote: >> >> How do I do the same thing if the string param is a utf-8 or utf-16 >string and the SearchChar is a Unicode character? > >Convert the characters to 32-bit wide characters first, then iterate >over the array of uint32_t or similar. > >One method is shown by the SQLite-internal function >sqlite3Utf8Read(). It’s static in the amalgamation build, but since >SQLite is public domain, you can just copy that function’s text out >into your program and use it there or modify it to suit your >purposes. > >Your platform libraries may have UTF-8 to UTF-32 or similar >mechanisms. > >On POSIX platforms, the most common of these is iconv(3). > >On Windows, the legacy of UCS-2 and UTF-16 makes this difficult, but >if you can stick to the Basic Multilingual Plane, converting UTF-8 to >UCS-2 gives the same effect. See MultiByteToWideChar(…, CP_UTF8, …): > > https://docs.microsoft.com/windows/desktop/api/stringapiset/nf- >stringapiset-multibytetowidechar > >For all platforms, there’s ICU. That’s of particular interest with >SQLite since there’s an included ICU extension you can include to get >more Unicode power in SQLite: > > https://www.sqlite.org/compile.html#enable_icu > >There are complications that your questions don’t push into, but >beware that if you start getting beyond simple “character in string” >questions, you’ll eventually have to confront them: combining >characters, etc. >_______________________________________________ >sqlite-users mailing list >sqlite-users@mailinglists.sqlite.org >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users