BigQuery Function

CREATE OR REPLACE FUNCTION `project.database.accent_clean`(txt STRING) RETURNS STRING LANGUAGE js
OPTIONS (description="Removes accented characters that can be troublesome and replaces with plain characters.") AS R"""
var accents = /[ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,ø,Ø,Å,Á,À,Â,Ä,È,É,Ê,Ë,Í,Î,Ï,Ì,Ò,Ó,Ô,Ö,Ú,Ù,Û,Ü,Ÿ,Ç,Æ,Œ,ñ]/g

  var replacements = {'ç':'c', 'æ':'ae', 'œ':'oe', 'á':'a', 'é':'e', 'í':'i', 'ó':'o', 'ú':'u', 'à':'a', 'è':'e', 'ì':'i', 'ò':'o', 'ù':'u', 'ä':'a', 'ë':'e', 'ï':'i', 'ö':'o', 'ü':'u', 'ÿ':'y', 'â':'a', 'ê':'e', 'î':'i', 'ô':'o', 'û':'u', 'å':'a', 'ø':'o', 'Ø':'O', 'Å':'A', 'Á':'A', 'À':'A', 'Â':'A', 'Ä':'A', 'È':'E', 'É':'E', 'Ê':'E', 'Ë':'E', 'Í':'I', 'Î':'I', 'Ï':'I', 'Ì':'I', 'Ò':'O', 'Ó':'O', 'Ô':'O', 'Ö':'O', 'Ú':'U', 'Ù':'U', 'Û':'U', 'Ü':'U', 'Ÿ':'Y', 'Ç':'C', 'Æ':'AE', 'Œ':'OE', 'ñ':'n'};
  
  var rtn = txt.replace(accents, m => replacements[m]);
  return rtn
""";
CheneyPinata