Case-insensitive UTF-8 string collation for SQLite (C/C++)

前端 未结 6 802
一个人的身影
一个人的身影 2021-02-09 04:58

I am looking for a method to compare and sort UTF-8 strings in C++ in a case-insensitive manner to use it in a custom collation function in SQLite.

  1. The method shou
6条回答
  •  无人共我
    2021-02-09 05:41

    If you are using it to do searching and sorting for your locale only, I suggest your function to call a simple replace function that convert both multi-byte strings into one byte per char ones using a table like:

    A -> a
    Ã -> a
    á -> a
    ß -> ss
    Ç -> c
    and so on

    Then simply call strcmp and return the results.

提交回复
热议问题