normalizeHebrewQuote static method
- String str
Replace the double and single quote directly after a Hebrew character in
str
with GERESH and GERSHAYIM. This is most likely the user's intention.
Implementation
static String normalizeHebrewQuote(String str) {
var buf = StringBuffer();
if (str.isNotEmpty) {
buf.write(str.substring(0, 1));
}
// Start at 1 because we're looking for the patterns [\u0591-\u05f2])" or
// [\u0591-\u05f2]'.
for (var i = 1; i < str.length; i++) {
if (str.substring(i, i + 1) == '"' &&
RegExp('[\u0591-\u05f2]').hasMatch(str.substring(i - 1, i))) {
buf.write('\u05f4');
} else if (str.substring(i, i + 1) == "'" &&
RegExp('[\u0591-\u05f2]').hasMatch(str.substring(i - 1, i))) {
buf.write('\u05f3');
} else {
buf.write(str.substring(i, i + 1));
}
}
return buf.toString();
}