Users submitted those weird characters. How to sort them along with normal text in Dart ?
𝔦𝔠𝔦𝔞𝔩𝔞
𝓕𝓪𝓴𝓷𝓬𝓻𝓪
𝗺𝗹𝗲𝗖𝗹𝗮𝗿𝗮
𝙖𝙨𝙡𝙖𝙜𝙖𝙈𝙮
𝖧𝗋𝗂𝖾
𝑮𝒂𝒍𝒍𝒆𝒂
𝐿𝑢𝑛𝑎
𝐃𝐡𝐢𝐚
𝕠ℝ𝕒𝕥𝕧𝕒𝕠𝕜𝕠
The good old
b.name.toLowerCase().compareTo(a.name.toLowerCase()); does not work
Users submitted those weird characters. How to sort them along with normal text in Dart ?
𝔦𝔠𝔦𝔞𝔩𝔞
𝓕𝓪𝓴𝓷𝓬𝓻𝓪
𝗺𝗹𝗲𝗖𝗹𝗮𝗿𝗮
𝙖𝙨𝙡𝙖𝙜𝙖𝙈𝙮
𝖧𝗋𝗂𝖾
𝑮𝒂𝒍𝒍𝒆𝒂
𝐿𝑢𝑛𝑎
𝐃𝐡𝐢𝐚
𝕠ℝ𝕒𝕥𝕧𝕒𝕠𝕜𝕠
The good old
b.name.toLowerCase().compareTo(a.name.toLowerCase()); does not work
UPDATE: Just found https://pub.dev/packages/diacritic, which appears as though it might do roughly what you want, although I'm not sure of how many different characters it supports.
Well, a good place to start might be looking at the internal implementation of the ES6 String.prototype.normalize() function.
Interestingly, it only works in Compatibility Decomposition mode - ie. NFKC or NFKD.
for (const weirdString of [
'𝔦𝔠𝔦𝔞𝔩𝔞',
'𝓕𝓪𝓴𝓷𝓬𝓻𝓪',
'𝗺𝗹𝗲𝗖𝗹𝗮𝗿𝗮',
'𝙖𝙨𝙡𝙖𝙜𝙖𝙈𝙮',
'𝖧𝗋𝗂𝖾',
'𝑮𝒂𝒍𝒍𝒆𝒂',
'𝐿𝑢𝑛𝑎',
'𝐃𝐡𝐢𝐚',
'𝕠ℝ𝕒𝕥𝕧𝕒𝕠𝕜𝕠',
]) {console.log(weirdString.normalize('NFKC'))}
Anyway, maybe there is a translation in Dart, or you can use the 'dart:js' library if you're running on the web, or you could find the implementation in the V8 engine (although it'll probably be in C).