swu2fsw function
Implementation
String swu2fsw(String swuText) {
if (swuText.isEmpty) {
return '';
}
// Initial replacements to convert SWU characters to FSW characters
String fsw = swuText
.replaceAll("𝠀", "A")
.replaceAll("𝠁", "B")
.replaceAll("𝠂", "L")
.replaceAll("𝠃", "M")
.replaceAll("𝠄", "R");
// Replacing SWU symbols with FSW keys
RegExp symbolRegex = RegExp(ReSwu.symbol, unicode: true);
Iterable<RegExpMatch> symbols = symbolRegex.allMatches(fsw);
if (symbols.isNotEmpty) {
for (RegExpMatch sym in symbols) {
fsw = fsw.replaceAll(sym.group(0)!, swu2key(sym.group(0)!));
}
}
// Converting SWU coordinates to FSW coordinates
RegExp coordRegex = RegExp(ReSwu.coord, unicode: true);
Iterable<RegExpMatch> coords = coordRegex.allMatches(fsw);
if (coords.isNotEmpty) {
for (RegExpMatch coord in coords) {
fsw = fsw.replaceAll(
coord.group(0)!,
swu2coord(coord.group(0)!).join('x'),
);
}
}
return fsw;
}