deAccentVietnamese method

String deAccentVietnamese()

Implementation

String deAccentVietnamese() {
  var result = this;
  const aList = ["à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă","ằ","ắ","ặ","ẳ","ẵ"];
  const eList = ["è","é","ẹ","ẻ","ẽ","ê","ề","ế","ệ","ể","ễ"];
  const iList = ["ì","í","ị","ỉ","ĩ"];
  const oList = ["ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ","ờ","ớ","ợ","ở","ỡ"];
  const uList = ["ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ"];
  const yList = ["ỳ","ý","ỵ","ỷ","ỹ"];
  const dList = ["đ"];
  const AList = ["À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă","Ằ","Ắ","Ặ","Ẳ","Ẵ"];
  const EList = ["È","É","Ẹ","Ẻ","Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ"];
  const IList = ["Ì","Í","Ị","Ỉ","Ĩ"];
  const OList = ["Ò","Ó","Ọ","Ỏ","Õ","Ô","Ồ","Ố","Ộ","Ổ","Ỗ","Ơ","Ờ","Ớ","Ợ","Ở","Ỡ"];
  const UList = ["Ù","Ú","Ụ","Ủ","Ũ","Ư","Ừ","Ứ","Ự","Ử","Ữ"];
  const YList = ["Ỳ","Ý","Ỵ","Ỷ","Ỹ"];
  const DList = ["Đ"];

  for (final pattern in aList) { result = result.replaceAll(pattern, "a"); }
  for (final pattern in eList) { result = result.replaceAll(pattern, "e"); }
  for (final pattern in iList) { result = result.replaceAll(pattern, "i"); }
  for (final pattern in oList) { result = result.replaceAll(pattern, "o"); }
  for (final pattern in uList) { result = result.replaceAll(pattern, "u"); }
  for (final pattern in yList) { result = result.replaceAll(pattern, "y"); }
  for (final pattern in dList) { result = result.replaceAll(pattern, "d"); }
  for (final pattern in AList) { result = result.replaceAll(pattern, "A"); }
  for (final pattern in EList) { result = result.replaceAll(pattern, "E"); }
  for (final pattern in IList) { result = result.replaceAll(pattern, "I"); }
  for (final pattern in OList) { result = result.replaceAll(pattern, "O"); }
  for (final pattern in UList) { result = result.replaceAll(pattern, "U"); }
  for (final pattern in YList) { result = result.replaceAll(pattern, "Y"); }
  for (final pattern in DList) { result = result.replaceAll(pattern, "D"); }

  return result;
}