[M1 Mac, Monterey 12.3, FLTK 1.3.8]
macOSではfindコマンドの検索語に濁音・半濁音のかなを使えないため、これらを判定する関数を実装しました。イテレータを使えるケースですが、今回は不使用です。
正規表現が使えないようなので地道に配列を作成しました。検出するとダイアログが表示されます。
std::vector<string> dakuon = {"が","ぎ","ぐ","げ","ご","ざ","じ","ず","ぜ","ぞ","だ","ぢ","づ","で","ど","ば","び","ぶ","べ","ぼ" \
"ガ","ギ","グ","ゲ","ゴ","ザ","ジ","ズ","ゼ","ゾ","ダ","ヂ","ヅ","デ","ド","バ","ビ","ブ","ベ","ボ" \
"ぱ","ぴ","ぷ","ぺ","ぽ","パ","ピ","プ","ペ","ポ"};
bool dakuon_detection(const char* name_char) {
string name_str = string(name_char);
for (size_t i = 0; i < dakuon.size(); ++i) {
if (name_str.find(dakuon[i]) != std::string::npos) {
const char* msg = "検索不可\n濁音・半濁音の平仮名・片仮名が\n含まれています";
dlg = new modalDialog(400, 200, "Attention", msg);
dlg->hotspot(window);
int x = dlg->x_root();
int y = dlg->y_root();
dlg->resize(x+20,y+120,250,150);
dlg->set_modal();
dlg->show();
cout << msg << endl;
return true;
}
}
return false;
}
bool judge = dakuon_detection(name_char);
if (judge){
<濁音かな検出時の処理>
}else{
<濁音かな非検出時の処理>
}