Skip to main content
October 4, 2023
Question

Removing accents from letters

  • October 4, 2023
  • 3 replies
  • 0 views

Hello,

I was wondering if there was a function which takes as input a string and returns the same string stripped of any accents (ex: été -> ete). If not, what would be the most efficient way of achieving this result within an expression rule?

Thank you

3 replies

October 4, 2023

a!localVariables(
  local!splitted_text: a!forEach(
    items: enumerate(len(ri!text)),
    expression: charat(ri!text, fv!index)
  ),
  local!splCharsReplacedArray_txt: a!forEach(
    items: local!splitted_text,
    expression: if(
      isnull(clean(fv!item)),
      displayvalue(
        fv!item,
        {"Ã%A0","á","â","ã","ä","ç","è","é","ê","ë","ì","Ã%AD","î","ï","ñ","ò","ó","ô","õ","ö","Å¡","ù","ú","û","ü","ý","ÿ","ž","Ã`","Ã%81","Â","Ã","Ä","Ç","È","É","Ê","Ë","ÃŒ","Ã%8D","ÃŽ","Ã%8F","Ñ","Ã’","Ó","Ô","Õ","Ö","Å%A0","Ú","Û","Ü","Ù","Ã%9D","Ÿ","Ž"},
        {"a","a","a","a","a","c","e","e","e","e","i","i","i","i","n","0","o","o","o","o","s","u","u","u","u","y","y","z","A","A","A","A","A","C","E","E","E","E","I","I","I","I","N","O","O","O","O","O","S","U","U","U","U","Y","Y","Z"},
        ""),
      fv!item
    )
  ),
  joinarray(local!splCharsReplacedArray_txt, "")
)
This is what I have so far but it seems very inefficient 

mathieud0001
Brainy
October 4, 2023

a!localVariables(
  local!keys: {
    "Ã%A0",
    "á",
    "â",
    "ã",
    "ä",
    "ç",
    "è",
    "é",
    "ê",
    "ë",
    "ì",
    "Ã%AD",
    "î",
    "ï",
    "ñ",
    "ò",
    "ó",
    "ô",
    "õ",
    "ö",
    "Å¡",
    "ù",
    "ú",
    "û",
    "ü",
    "ý",
    "ÿ",
    "ž",
    "Ã`",
    "Ã%81",
    "Â",
    "Ã",
    "Ä",
    "Ç",
    "È",
    "É",
    "Ê",
    "Ë",
    "Ì",
    "Ã%8D",
    "ÃŽ",
    "Ã%8F",
    "Ñ",
    "Ã’",
    "Ó",
    "Ô",
    "Õ",
    "Ö",
    "Å%A0",
    "Ú",
    "Û",
    "Ü",
    "Ù",
    "Ã%9D",
    "Ÿ",
    "Ž"
  },
  local!values: {
    "a",
    "a",
    "a",
    "a",
    "a",
    "c",
    "e",
    "e",
    "e",
    "e",
    "i",
    "i",
    "i",
    "i",
    "n",
    "0",
    "o",
    "o",
    "o",
    "o",
    "s",
    "u",
    "u",
    "u",
    "u",
    "y",
    "y",
    "z",
    "A",
    "A",
    "A",
    "A",
    "A",
    "C",
    "E",
    "E",
    "E",
    "E",
    "I",
    "I",
    "I",
    "I",
    "N",
    "O",
    "O",
    "O",
    "O",
    "O",
    "S",
    "U",
    "U",
    "U",
    "U",
    "Y",
    "Y",
    "Z"
  },
  reduce(
    substitute(_, _, _),
    ri!text,
    merge(local!keys, local!values)
  )
)