toZenkakuNumericAndAlphabet method

String toZenkakuNumericAndAlphabet()

Converts alphabets and numbers to full-width characters.

アルファベットと数字を全角に変換します。

final text = "abcd";
final converted = text.toZenkakuNumericAndAlphabet(); // "abcd"

Implementation

String toZenkakuNumericAndAlphabet() {
  final regex = RegExp(r'^[a-zA-Z0-9]+$');
  final string = runes.map<String>((rune) {
    final char = String.fromCharCode(rune);
    return regex.hasMatch(char) ? String.fromCharCode(rune + 65248) : char;
  });
  return string.join();
}