Eliminating Unicode accents in Apex

This is a newer revision of Adrian Larson's previous answer for benchmark comparison.

This should work quite well for short-ish text fields quite well at the expense of some bytes of heap. For a longer text field, it takes longer.

Long story short, if you have very limited heap space (or disk space), it might make sense to use Adrian's method. Also, if you can spare performance in exchange for legibility, Adrian's is certainly better! If you have ~19kB of disk space and 17kB heap, this is more performant.

Test results

Environment: CS61 sandbox through anonymous apex on Spring '17 Patch 4

Test Suite: Strings with an unusually-high percentage of accented characters. Taken from TextMechanic.com.

This code

  • Heap: 16980
  • Disk: 18664
  • Runs on 660-char: 2.6ms
  • Runs on 255-char: 1ms
  • Runs on shortish strings: 0.2ms

Adrian's code

  • Heap: 3154
  • Disk: 6933
  • Runs on 660-char: 8.1ms (surprisingly bad Regex perf!)
  • Runs on 255-char: 3.3ms
  • Runs on shortish strings: 1.2ms
  static Integer[] A_CHARS_U = new Integer[]{65};
  static Integer[] AA_CHARS_UU = new Integer[]{65,65};
  static Integer[] AE_CHARS_UU = new Integer[]{65,69};
  static Integer[] AO_CHARS_UU = new Integer[]{65,79};
  static Integer[] AU_CHARS_UU = new Integer[]{65,85};
  static Integer[] AV_CHARS_UU = new Integer[]{65,86};
  static Integer[] AY_CHARS_UU = new Integer[]{65,89};
  static Integer[] B_CHARS_U = new Integer[]{66};
  static Integer[] C_CHARS_U = new Integer[]{67};
  static Integer[] D_CHARS_U = new Integer[]{68};
  static Integer[] DZ_CHARS_UU = new Integer[]{68,90};
  static Integer[] DZ_CHARS_UL = new Integer[]{68,122};
  static Integer[] E_CHARS_U = new Integer[]{69};
  static Integer[] F_CHARS_U = new Integer[]{70};
  static Integer[] G_CHARS_U = new Integer[]{71};
  static Integer[] H_CHARS_U = new Integer[]{72};
  static Integer[] I_CHARS_U = new Integer[]{73};
  static Integer[] J_CHARS_U = new Integer[]{74};
  static Integer[] K_CHARS_U = new Integer[]{75};
  static Integer[] L_CHARS_U = new Integer[]{76};
  static Integer[] LJ_CHARS_UU = new Integer[]{76,74};
  static Integer[] LJ_CHARS_UL = new Integer[]{76,106};
  static Integer[] M_CHARS_U = new Integer[]{77};
  static Integer[] N_CHARS_U = new Integer[]{78};
  static Integer[] NJ_CHARS_UU = new Integer[]{78,74};
  static Integer[] NJ_CHARS_UL = new Integer[]{78,106};
  static Integer[] O_CHARS_U = new Integer[]{79};
  static Integer[] OI_CHARS_UU = new Integer[]{79,73};
  static Integer[] OO_CHARS_UU = new Integer[]{79,79};
  static Integer[] OU_CHARS_UU = new Integer[]{79,85};
  static Integer[] P_CHARS_U = new Integer[]{80};
  static Integer[] Q_CHARS_U = new Integer[]{81};
  static Integer[] R_CHARS_U = new Integer[]{82};
  static Integer[] S_CHARS_U = new Integer[]{83};
  static Integer[] T_CHARS_U = new Integer[]{84};
  static Integer[] TZ_CHARS_UU = new Integer[]{84,90};
  static Integer[] U_CHARS_U = new Integer[]{85};
  static Integer[] V_CHARS_U = new Integer[]{86};
  static Integer[] VY_CHARS_UU = new Integer[]{86,89};
  static Integer[] W_CHARS_U = new Integer[]{87};
  static Integer[] X_CHARS_U = new Integer[]{88};
  static Integer[] Y_CHARS_U = new Integer[]{89};
  static Integer[] Z_CHARS_U = new Integer[]{90};
  static Integer[] A_CHARS_L = new Integer[]{97};
  static Integer[] AA_CHARS_LL = new Integer[]{97,97};
  static Integer[] AE_CHARS_LL = new Integer[]{97,101};
  static Integer[] AO_CHARS_LL = new Integer[]{97,111};
  static Integer[] AU_CHARS_LL = new Integer[]{97,117};
  static Integer[] AV_CHARS_LL = new Integer[]{97,118};
  static Integer[] AY_CHARS_LL = new Integer[]{97,121};
  static Integer[] B_CHARS_L = new Integer[]{98};
  static Integer[] C_CHARS_L = new Integer[]{99};
  static Integer[] D_CHARS_L = new Integer[]{100};
  static Integer[] DZ_CHARS_LL = new Integer[]{100,122};
  static Integer[] E_CHARS_L = new Integer[]{101};
  static Integer[] F_CHARS_L = new Integer[]{102};
  static Integer[] G_CHARS_L = new Integer[]{103};
  static Integer[] H_CHARS_L = new Integer[]{104};
  static Integer[] HV_CHARS_LL = new Integer[]{104,118};
  static Integer[] I_CHARS_L = new Integer[]{105};
  static Integer[] J_CHARS_L = new Integer[]{106};
  static Integer[] K_CHARS_L = new Integer[]{107};
  static Integer[] L_CHARS_L = new Integer[]{108};
  static Integer[] LJ_CHARS_LL = new Integer[]{108,106};
  static Integer[] M_CHARS_L = new Integer[]{109};
  static Integer[] N_CHARS_L = new Integer[]{110};
  static Integer[] NJ_CHARS_LL = new Integer[]{110,106};
  static Integer[] O_CHARS_L = new Integer[]{111};
  static Integer[] OI_CHARS_LL = new Integer[]{111,105};
  static Integer[] OU_CHARS_LL = new Integer[]{111,117};
  static Integer[] OO_CHARS_LL = new Integer[]{111,111};
  static Integer[] P_CHARS_L = new Integer[]{112};
  static Integer[] Q_CHARS_L = new Integer[]{113};
  static Integer[] R_CHARS_L = new Integer[]{114};
  static Integer[] S_CHARS_L = new Integer[]{115};
  static Integer[] T_CHARS_L = new Integer[]{116};
  static Integer[] TZ_CHARS_LL = new Integer[]{116,122};
  static Integer[] U_CHARS_L = new Integer[]{117};
  static Integer[] V_CHARS_L = new Integer[]{118};
  static Integer[] VY_CHARS_LL = new Integer[]{118,121};
  static Integer[] W_CHARS_L = new Integer[]{119};
  static Integer[] X_CHARS_L = new Integer[]{120};
  static Integer[] Y_CHARS_L = new Integer[]{121};
  static Integer[] Z_CHARS_L = new Integer[]{122};

  static Map<Integer, List<Integer>> DIACRITIC_MAP = new Map<Integer, List<Integer>>{
    65=>A_CHARS_U,9398=>A_CHARS_U,65313=>A_CHARS_U,192=>A_CHARS_U,193=>A_CHARS_U,194=>A_CHARS_U,7846=>A_CHARS_U,7844=>A_CHARS_U,7850=>A_CHARS_U,7848=>A_CHARS_U,195=>A_CHARS_U,256=>A_CHARS_U,258=>A_CHARS_U,7856=>A_CHARS_U,7854=>A_CHARS_U,7860=>A_CHARS_U,7858=>A_CHARS_U,550=>A_CHARS_U,480=>A_CHARS_U,196=>A_CHARS_U,478=>A_CHARS_U,7842=>A_CHARS_U,197=>A_CHARS_U,506=>A_CHARS_U,461=>A_CHARS_U,512=>A_CHARS_U,514=>A_CHARS_U,7840=>A_CHARS_U,7852=>A_CHARS_U,7862=>A_CHARS_U,7680=>A_CHARS_U,260=>A_CHARS_U,570=>A_CHARS_U,11375=>A_CHARS_U,42802=>AA_CHARS_UU,198=>AE_CHARS_UU,508=>AE_CHARS_UU,482=>AE_CHARS_UU,42804=>AO_CHARS_UU,42806=>AU_CHARS_UU,42808=>AV_CHARS_UU,42810=>AV_CHARS_UU,42812=>AY_CHARS_UU,66=>B_CHARS_U,9399=>B_CHARS_U,65314=>B_CHARS_U,7682=>B_CHARS_U,7684=>B_CHARS_U,7686=>B_CHARS_U,579=>B_CHARS_U,386=>B_CHARS_U,385=>B_CHARS_U,67=>C_CHARS_U,9400=>C_CHARS_U,65315=>C_CHARS_U,262=>C_CHARS_U,264=>C_CHARS_U,266=>C_CHARS_U,268=>C_CHARS_U,199=>C_CHARS_U,7688=>C_CHARS_U,391=>C_CHARS_U,571=>C_CHARS_U,42814=>C_CHARS_U,68=>D_CHARS_U,9401=>D_CHARS_U,65316=>D_CHARS_U,7690=>D_CHARS_U,270=>D_CHARS_U,7692=>D_CHARS_U,7696=>D_CHARS_U,7698=>D_CHARS_U,7694=>D_CHARS_U,272=>D_CHARS_U,395=>D_CHARS_U,394=>D_CHARS_U,393=>D_CHARS_U,42873=>D_CHARS_U,497=>DZ_CHARS_UU,452=>DZ_CHARS_UU,498=>DZ_CHARS_UL,453=>DZ_CHARS_UL,69=>E_CHARS_U,9402=>E_CHARS_U,65317=>E_CHARS_U,200=>E_CHARS_U,201=>E_CHARS_U,202=>E_CHARS_U,7872=>E_CHARS_U,7870=>E_CHARS_U,7876=>E_CHARS_U,7874=>E_CHARS_U,7868=>E_CHARS_U,274=>E_CHARS_U,7700=>E_CHARS_U,7702=>E_CHARS_U,276=>E_CHARS_U,278=>E_CHARS_U,203=>E_CHARS_U,7866=>E_CHARS_U,282=>E_CHARS_U,516=>E_CHARS_U,518=>E_CHARS_U,7864=>E_CHARS_U,7878=>E_CHARS_U,552=>E_CHARS_U,7708=>E_CHARS_U,280=>E_CHARS_U,7704=>E_CHARS_U,7706=>E_CHARS_U,400=>E_CHARS_U,398=>E_CHARS_U,70=>F_CHARS_U,9403=>F_CHARS_U,65318=>F_CHARS_U,7710=>F_CHARS_U,401=>F_CHARS_U,42875=>F_CHARS_U,71=>G_CHARS_U,9404=>G_CHARS_U,65319=>G_CHARS_U,500=>G_CHARS_U,284=>G_CHARS_U,7712=>G_CHARS_U,286=>G_CHARS_U,288=>G_CHARS_U,486=>G_CHARS_U,290=>G_CHARS_U,484=>G_CHARS_U,403=>G_CHARS_U,42912=>G_CHARS_U,42877=>G_CHARS_U,42878=>G_CHARS_U,72=>H_CHARS_U,9405=>H_CHARS_U,65320=>H_CHARS_U,292=>H_CHARS_U,7714=>H_CHARS_U,7718=>H_CHARS_U,542=>H_CHARS_U,7716=>H_CHARS_U,7720=>H_CHARS_U,7722=>H_CHARS_U,294=>H_CHARS_U,11367=>H_CHARS_U,11381=>H_CHARS_U,42893=>H_CHARS_U,73=>I_CHARS_U,9406=>I_CHARS_U,65321=>I_CHARS_U,204=>I_CHARS_U,205=>I_CHARS_U,206=>I_CHARS_U,296=>I_CHARS_U,298=>I_CHARS_U,300=>I_CHARS_U,304=>I_CHARS_U,207=>I_CHARS_U,7726=>I_CHARS_U,7880=>I_CHARS_U,463=>I_CHARS_U,520=>I_CHARS_U,522=>I_CHARS_U,7882=>I_CHARS_U,302=>I_CHARS_U,7724=>I_CHARS_U,407=>I_CHARS_U,74=>J_CHARS_U,9407=>J_CHARS_U,65322=>J_CHARS_U,308=>J_CHARS_U,584=>J_CHARS_U,75=>K_CHARS_U,9408=>K_CHARS_U,65323=>K_CHARS_U,7728=>K_CHARS_U,488=>K_CHARS_U,7730=>K_CHARS_U,310=>K_CHARS_U,7732=>K_CHARS_U,408=>K_CHARS_U,11369=>K_CHARS_U,42816=>K_CHARS_U,42818=>K_CHARS_U,42820=>K_CHARS_U,42914=>K_CHARS_U,76=>L_CHARS_U,9409=>L_CHARS_U,65324=>L_CHARS_U,319=>L_CHARS_U,313=>L_CHARS_U,317=>L_CHARS_U,7734=>L_CHARS_U,7736=>L_CHARS_U,315=>L_CHARS_U,7740=>L_CHARS_U,7738=>L_CHARS_U,321=>L_CHARS_U,573=>L_CHARS_U,11362=>L_CHARS_U,11360=>L_CHARS_U,42824=>L_CHARS_U,42822=>L_CHARS_U,42880=>L_CHARS_U,455=>LJ_CHARS_UU,456=>LJ_CHARS_UL,77=>M_CHARS_U,9410=>M_CHARS_U,65325=>M_CHARS_U,7742=>M_CHARS_U,7744=>M_CHARS_U,7746=>M_CHARS_U,11374=>M_CHARS_U,412=>M_CHARS_U,78=>N_CHARS_U,9411=>N_CHARS_U,65326=>N_CHARS_U,504=>N_CHARS_U,323=>N_CHARS_U,209=>N_CHARS_U,7748=>N_CHARS_U,327=>N_CHARS_U,7750=>N_CHARS_U,325=>N_CHARS_U,7754=>N_CHARS_U,7752=>N_CHARS_U,544=>N_CHARS_U,413=>N_CHARS_U,42896=>N_CHARS_U,42916=>N_CHARS_U,458=>NJ_CHARS_UU,459=>NJ_CHARS_UL,79=>O_CHARS_U,9412=>O_CHARS_U,65327=>O_CHARS_U,210=>O_CHARS_U,211=>O_CHARS_U,212=>O_CHARS_U,7890=>O_CHARS_U,7888=>O_CHARS_U,7894=>O_CHARS_U,7892=>O_CHARS_U,213=>O_CHARS_U,7756=>O_CHARS_U,556=>O_CHARS_U,7758=>O_CHARS_U,332=>O_CHARS_U,7760=>O_CHARS_U,7762=>O_CHARS_U,334=>O_CHARS_U,558=>O_CHARS_U,560=>O_CHARS_U,214=>O_CHARS_U,554=>O_CHARS_U,7886=>O_CHARS_U,336=>O_CHARS_U,465=>O_CHARS_U,524=>O_CHARS_U,526=>O_CHARS_U,416=>O_CHARS_U,7900=>O_CHARS_U,7898=>O_CHARS_U,7904=>O_CHARS_U,7902=>O_CHARS_U,7906=>O_CHARS_U,7884=>O_CHARS_U,7896=>O_CHARS_U,490=>O_CHARS_U,492=>O_CHARS_U,216=>O_CHARS_U,510=>O_CHARS_U,390=>O_CHARS_U,415=>O_CHARS_U,42826=>O_CHARS_U,42828=>O_CHARS_U,418=>OI_CHARS_UU,42830=>OO_CHARS_UU,546=>OU_CHARS_UU,80=>P_CHARS_U,9413=>P_CHARS_U,65328=>P_CHARS_U,7764=>P_CHARS_U,7766=>P_CHARS_U,420=>P_CHARS_U,11363=>P_CHARS_U,42832=>P_CHARS_U,42834=>P_CHARS_U,42836=>P_CHARS_U,81=>Q_CHARS_U,9414=>Q_CHARS_U,65329=>Q_CHARS_U,42838=>Q_CHARS_U,42840=>Q_CHARS_U,586=>Q_CHARS_U,82=>R_CHARS_U,9415=>R_CHARS_U,65330=>R_CHARS_U,340=>R_CHARS_U,7768=>R_CHARS_U,344=>R_CHARS_U,528=>R_CHARS_U,530=>R_CHARS_U,7770=>R_CHARS_U,7772=>R_CHARS_U,342=>R_CHARS_U,7774=>R_CHARS_U,588=>R_CHARS_U,11364=>R_CHARS_U,42842=>R_CHARS_U,42918=>R_CHARS_U,42882=>R_CHARS_U,83=>S_CHARS_U,9416=>S_CHARS_U,65331=>S_CHARS_U,7838=>S_CHARS_U,346=>S_CHARS_U,7780=>S_CHARS_U,348=>S_CHARS_U,7776=>S_CHARS_U,352=>S_CHARS_U,7782=>S_CHARS_U,7778=>S_CHARS_U,7784=>S_CHARS_U,536=>S_CHARS_U,350=>S_CHARS_U,11390=>S_CHARS_U,42920=>S_CHARS_U,42884=>S_CHARS_U,84=>T_CHARS_U,9417=>T_CHARS_U,65332=>T_CHARS_U,7786=>T_CHARS_U,356=>T_CHARS_U,7788=>T_CHARS_U,538=>T_CHARS_U,354=>T_CHARS_U,7792=>T_CHARS_U,7790=>T_CHARS_U,358=>T_CHARS_U,428=>T_CHARS_U,430=>T_CHARS_U,574=>T_CHARS_U,42886=>T_CHARS_U,42792=>TZ_CHARS_UU,85=>U_CHARS_U,9418=>U_CHARS_U,65333=>U_CHARS_U,217=>U_CHARS_U,218=>U_CHARS_U,219=>U_CHARS_U,360=>U_CHARS_U,7800=>U_CHARS_U,362=>U_CHARS_U,7802=>U_CHARS_U,364=>U_CHARS_U,220=>U_CHARS_U,475=>U_CHARS_U,471=>U_CHARS_U,469=>U_CHARS_U,473=>U_CHARS_U,7910=>U_CHARS_U,366=>U_CHARS_U,368=>U_CHARS_U,467=>U_CHARS_U,532=>U_CHARS_U,534=>U_CHARS_U,431=>U_CHARS_U,7914=>U_CHARS_U,7912=>U_CHARS_U,7918=>U_CHARS_U,7916=>U_CHARS_U,7920=>U_CHARS_U,7908=>U_CHARS_U,7794=>U_CHARS_U,370=>U_CHARS_U,7798=>U_CHARS_U,7796=>U_CHARS_U,580=>U_CHARS_U,86=>V_CHARS_U,9419=>V_CHARS_U,65334=>V_CHARS_U,7804=>V_CHARS_U,7806=>V_CHARS_U,434=>V_CHARS_U,42846=>V_CHARS_U,581=>V_CHARS_U,42848=>VY_CHARS_UU,87=>W_CHARS_U,9420=>W_CHARS_U,65335=>W_CHARS_U,7808=>W_CHARS_U,7810=>W_CHARS_U,372=>W_CHARS_U,7814=>W_CHARS_U,7812=>W_CHARS_U,7816=>W_CHARS_U,11378=>W_CHARS_U,88=>X_CHARS_U,9421=>X_CHARS_U,65336=>X_CHARS_U,7818=>X_CHARS_U,7820=>X_CHARS_U,89=>Y_CHARS_U,9422=>Y_CHARS_U,65337=>Y_CHARS_U,7922=>Y_CHARS_U,221=>Y_CHARS_U,374=>Y_CHARS_U,7928=>Y_CHARS_U,562=>Y_CHARS_U,7822=>Y_CHARS_U,376=>Y_CHARS_U,7926=>Y_CHARS_U,7924=>Y_CHARS_U,435=>Y_CHARS_U,590=>Y_CHARS_U,7934=>Y_CHARS_U,90=>Z_CHARS_U,9423=>Z_CHARS_U,65338=>Z_CHARS_U,377=>Z_CHARS_U,7824=>Z_CHARS_U,379=>Z_CHARS_U,381=>Z_CHARS_U,7826=>Z_CHARS_U,7828=>Z_CHARS_U,437=>Z_CHARS_U,548=>Z_CHARS_U,11391=>Z_CHARS_U,11371=>Z_CHARS_U,42850=>Z_CHARS_U,97=>A_CHARS_L,9424=>A_CHARS_L,65345=>A_CHARS_L,7834=>A_CHARS_L,224=>A_CHARS_L,225=>A_CHARS_L,226=>A_CHARS_L,7847=>A_CHARS_L,7845=>A_CHARS_L,7851=>A_CHARS_L,7849=>A_CHARS_L,227=>A_CHARS_L,257=>A_CHARS_L,259=>A_CHARS_L,7857=>A_CHARS_L,7855=>A_CHARS_L,7861=>A_CHARS_L,7859=>A_CHARS_L,551=>A_CHARS_L,481=>A_CHARS_L,228=>A_CHARS_L,479=>A_CHARS_L,7843=>A_CHARS_L,229=>A_CHARS_L,507=>A_CHARS_L,462=>A_CHARS_L,513=>A_CHARS_L,515=>A_CHARS_L,7841=>A_CHARS_L,7853=>A_CHARS_L,7863=>A_CHARS_L,7681=>A_CHARS_L,261=>A_CHARS_L,11365=>A_CHARS_L,592=>A_CHARS_L,42803=>AA_CHARS_LL,230=>AE_CHARS_LL,509=>AE_CHARS_LL,483=>AE_CHARS_LL,42805=>AO_CHARS_LL,42807=>AU_CHARS_LL,42809=>AV_CHARS_LL,42811=>AV_CHARS_LL,42813=>AY_CHARS_LL,98=>B_CHARS_L,9425=>B_CHARS_L,65346=>B_CHARS_L,7683=>B_CHARS_L,7685=>B_CHARS_L,7687=>B_CHARS_L,384=>B_CHARS_L,387=>B_CHARS_L,595=>B_CHARS_L,99=>C_CHARS_L,9426=>C_CHARS_L,65347=>C_CHARS_L,263=>C_CHARS_L,265=>C_CHARS_L,267=>C_CHARS_L,269=>C_CHARS_L,231=>C_CHARS_L,7689=>C_CHARS_L,392=>C_CHARS_L,572=>C_CHARS_L,42815=>C_CHARS_L,8580=>C_CHARS_L,100=>D_CHARS_L,9427=>D_CHARS_L,65348=>D_CHARS_L,7691=>D_CHARS_L,271=>D_CHARS_L,7693=>D_CHARS_L,7697=>D_CHARS_L,7699=>D_CHARS_L,7695=>D_CHARS_L,273=>D_CHARS_L,396=>D_CHARS_L,598=>D_CHARS_L,599=>D_CHARS_L,42874=>D_CHARS_L,499=>DZ_CHARS_LL,454=>DZ_CHARS_LL,101=>E_CHARS_L,9428=>E_CHARS_L,65349=>E_CHARS_L,232=>E_CHARS_L,233=>E_CHARS_L,234=>E_CHARS_L,7873=>E_CHARS_L,7871=>E_CHARS_L,7877=>E_CHARS_L,7875=>E_CHARS_L,7869=>E_CHARS_L,275=>E_CHARS_L,7701=>E_CHARS_L,7703=>E_CHARS_L,277=>E_CHARS_L,279=>E_CHARS_L,235=>E_CHARS_L,7867=>E_CHARS_L,283=>E_CHARS_L,517=>E_CHARS_L,519=>E_CHARS_L,7865=>E_CHARS_L,7879=>E_CHARS_L,553=>E_CHARS_L,7709=>E_CHARS_L,281=>E_CHARS_L,7705=>E_CHARS_L,7707=>E_CHARS_L,583=>E_CHARS_L,603=>E_CHARS_L,477=>E_CHARS_L,102=>F_CHARS_L,9429=>F_CHARS_L,65350=>F_CHARS_L,7711=>F_CHARS_L,402=>F_CHARS_L,42876=>F_CHARS_L,103=>G_CHARS_L,9430=>G_CHARS_L,65351=>G_CHARS_L,501=>G_CHARS_L,285=>G_CHARS_L,7713=>G_CHARS_L,287=>G_CHARS_L,289=>G_CHARS_L,487=>G_CHARS_L,291=>G_CHARS_L,485=>G_CHARS_L,608=>G_CHARS_L,42913=>G_CHARS_L,7545=>G_CHARS_L,42879=>G_CHARS_L,104=>H_CHARS_L,9431=>H_CHARS_L,65352=>H_CHARS_L,293=>H_CHARS_L,7715=>H_CHARS_L,7719=>H_CHARS_L,543=>H_CHARS_L,7717=>H_CHARS_L,7721=>H_CHARS_L,7723=>H_CHARS_L,7830=>H_CHARS_L,295=>H_CHARS_L,11368=>H_CHARS_L,11382=>H_CHARS_L,613=>H_CHARS_L,405=>HV_CHARS_LL,105=>I_CHARS_L,9432=>I_CHARS_L,65353=>I_CHARS_L,236=>I_CHARS_L,237=>I_CHARS_L,238=>I_CHARS_L,297=>I_CHARS_L,299=>I_CHARS_L,301=>I_CHARS_L,239=>I_CHARS_L,7727=>I_CHARS_L,7881=>I_CHARS_L,464=>I_CHARS_L,521=>I_CHARS_L,523=>I_CHARS_L,7883=>I_CHARS_L,303=>I_CHARS_L,7725=>I_CHARS_L,616=>I_CHARS_L,305=>I_CHARS_L,106=>J_CHARS_L,9433=>J_CHARS_L,65354=>J_CHARS_L,309=>J_CHARS_L,496=>J_CHARS_L,585=>J_CHARS_L,107=>K_CHARS_L,9434=>K_CHARS_L,65355=>K_CHARS_L,7729=>K_CHARS_L,489=>K_CHARS_L,7731=>K_CHARS_L,311=>K_CHARS_L,7733=>K_CHARS_L,409=>K_CHARS_L,11370=>K_CHARS_L,42817=>K_CHARS_L,42819=>K_CHARS_L,42821=>K_CHARS_L,42915=>K_CHARS_L,108=>L_CHARS_L,9435=>L_CHARS_L,65356=>L_CHARS_L,320=>L_CHARS_L,314=>L_CHARS_L,318=>L_CHARS_L,7735=>L_CHARS_L,7737=>L_CHARS_L,316=>L_CHARS_L,7741=>L_CHARS_L,7739=>L_CHARS_L,383=>L_CHARS_L,322=>L_CHARS_L,410=>L_CHARS_L,619=>L_CHARS_L,11361=>L_CHARS_L,42825=>L_CHARS_L,42881=>L_CHARS_L,42823=>L_CHARS_L,457=>LJ_CHARS_LL,109=>M_CHARS_L,9436=>M_CHARS_L,65357=>M_CHARS_L,7743=>M_CHARS_L,7745=>M_CHARS_L,7747=>M_CHARS_L,625=>M_CHARS_L,623=>M_CHARS_L,110=>N_CHARS_L,9437=>N_CHARS_L,65358=>N_CHARS_L,505=>N_CHARS_L,324=>N_CHARS_L,241=>N_CHARS_L,7749=>N_CHARS_L,328=>N_CHARS_L,7751=>N_CHARS_L,326=>N_CHARS_L,7755=>N_CHARS_L,7753=>N_CHARS_L,414=>N_CHARS_L,626=>N_CHARS_L,329=>N_CHARS_L,42897=>N_CHARS_L,42917=>N_CHARS_L,460=>NJ_CHARS_LL,111=>O_CHARS_L,9438=>O_CHARS_L,65359=>O_CHARS_L,242=>O_CHARS_L,243=>O_CHARS_L,244=>O_CHARS_L,7891=>O_CHARS_L,7889=>O_CHARS_L,7895=>O_CHARS_L,7893=>O_CHARS_L,245=>O_CHARS_L,7757=>O_CHARS_L,557=>O_CHARS_L,7759=>O_CHARS_L,333=>O_CHARS_L,7761=>O_CHARS_L,7763=>O_CHARS_L,335=>O_CHARS_L,559=>O_CHARS_L,561=>O_CHARS_L,246=>O_CHARS_L,555=>O_CHARS_L,7887=>O_CHARS_L,337=>O_CHARS_L,466=>O_CHARS_L,525=>O_CHARS_L,527=>O_CHARS_L,417=>O_CHARS_L,7901=>O_CHARS_L,7899=>O_CHARS_L,7905=>O_CHARS_L,7903=>O_CHARS_L,7907=>O_CHARS_L,7885=>O_CHARS_L,7897=>O_CHARS_L,491=>O_CHARS_L,493=>O_CHARS_L,248=>O_CHARS_L,511=>O_CHARS_L,596=>O_CHARS_L,42827=>O_CHARS_L,42829=>O_CHARS_L,629=>O_CHARS_L,419=>OI_CHARS_LL,547=>OU_CHARS_LL,42831=>OO_CHARS_LL,112=>P_CHARS_L,9439=>P_CHARS_L,65360=>P_CHARS_L,7765=>P_CHARS_L,7767=>P_CHARS_L,421=>P_CHARS_L,7549=>P_CHARS_L,42833=>P_CHARS_L,42835=>P_CHARS_L,42837=>P_CHARS_L,113=>Q_CHARS_L,9440=>Q_CHARS_L,65361=>Q_CHARS_L,587=>Q_CHARS_L,42839=>Q_CHARS_L,42841=>Q_CHARS_L,114=>R_CHARS_L,9441=>R_CHARS_L,65362=>R_CHARS_L,341=>R_CHARS_L,7769=>R_CHARS_L,345=>R_CHARS_L,529=>R_CHARS_L,531=>R_CHARS_L,7771=>R_CHARS_L,7773=>R_CHARS_L,343=>R_CHARS_L,7775=>R_CHARS_L,589=>R_CHARS_L,637=>R_CHARS_L,42843=>R_CHARS_L,42919=>R_CHARS_L,42883=>R_CHARS_L,115=>S_CHARS_L,9442=>S_CHARS_L,65363=>S_CHARS_L,223=>S_CHARS_L,347=>S_CHARS_L,7781=>S_CHARS_L,349=>S_CHARS_L,7777=>S_CHARS_L,353=>S_CHARS_L,7783=>S_CHARS_L,7779=>S_CHARS_L,7785=>S_CHARS_L,537=>S_CHARS_L,351=>S_CHARS_L,575=>S_CHARS_L,42921=>S_CHARS_L,42885=>S_CHARS_L,7835=>S_CHARS_L,116=>T_CHARS_L,9443=>T_CHARS_L,65364=>T_CHARS_L,7787=>T_CHARS_L,7831=>T_CHARS_L,357=>T_CHARS_L,7789=>T_CHARS_L,539=>T_CHARS_L,355=>T_CHARS_L,7793=>T_CHARS_L,7791=>T_CHARS_L,359=>T_CHARS_L,429=>T_CHARS_L,648=>T_CHARS_L,11366=>T_CHARS_L,42887=>T_CHARS_L,42793=>TZ_CHARS_LL,117=>U_CHARS_L,9444=>U_CHARS_L,65365=>U_CHARS_L,249=>U_CHARS_L,250=>U_CHARS_L,251=>U_CHARS_L,361=>U_CHARS_L,7801=>U_CHARS_L,363=>U_CHARS_L,7803=>U_CHARS_L,365=>U_CHARS_L,252=>U_CHARS_L,476=>U_CHARS_L,472=>U_CHARS_L,470=>U_CHARS_L,474=>U_CHARS_L,7911=>U_CHARS_L,367=>U_CHARS_L,369=>U_CHARS_L,468=>U_CHARS_L,533=>U_CHARS_L,535=>U_CHARS_L,432=>U_CHARS_L,7915=>U_CHARS_L,7913=>U_CHARS_L,7919=>U_CHARS_L,7917=>U_CHARS_L,7921=>U_CHARS_L,7909=>U_CHARS_L,7795=>U_CHARS_L,371=>U_CHARS_L,7799=>U_CHARS_L,7797=>U_CHARS_L,649=>U_CHARS_L,118=>V_CHARS_L,9445=>V_CHARS_L,65366=>V_CHARS_L,7805=>V_CHARS_L,7807=>V_CHARS_L,651=>V_CHARS_L,42847=>V_CHARS_L,652=>V_CHARS_L,42849=>VY_CHARS_LL,119=>W_CHARS_L,9446=>W_CHARS_L,65367=>W_CHARS_L,7809=>W_CHARS_L,7811=>W_CHARS_L,373=>W_CHARS_L,7815=>W_CHARS_L,7813=>W_CHARS_L,7832=>W_CHARS_L,7817=>W_CHARS_L,11379=>W_CHARS_L,120=>X_CHARS_L,9447=>X_CHARS_L,65368=>X_CHARS_L,7819=>X_CHARS_L,7821=>X_CHARS_L,121=>Y_CHARS_L,9448=>Y_CHARS_L,65369=>Y_CHARS_L,7923=>Y_CHARS_L,253=>Y_CHARS_L,375=>Y_CHARS_L,7929=>Y_CHARS_L,563=>Y_CHARS_L,7823=>Y_CHARS_L,255=>Y_CHARS_L,7927=>Y_CHARS_L,7833=>Y_CHARS_L,7925=>Y_CHARS_L,436=>Y_CHARS_L,591=>Y_CHARS_L,7935=>Y_CHARS_L,122=>Z_CHARS_L,9449=>Z_CHARS_L,65370=>Z_CHARS_L,378=>Z_CHARS_L,7825=>Z_CHARS_L,380=>Z_CHARS_L,382=>Z_CHARS_L,7827=>Z_CHARS_L,7829=>Z_CHARS_L,438=>Z_CHARS_L,549=>Z_CHARS_L,576=>Z_CHARS_L,11372=>Z_CHARS_L,42851=>Z_CHARS_L
  };

  // Thanks to Adrian Larson at https://salesforce.stackexchange.com/a/155379
  // and TextMechanic.com http://textmechanic.com/wp-content/uploads/source/Remove-Letter-Accents.html
  static String removeDiacritics(String str) {
    if (str == null) {
      return null;
    }
    List<Integer> result = new List<Integer>();
    for (Integer chr : str.getChars()) {
      if (DIACRITIC_MAP.containsKey(chr)) {
        result.addAll(DIACRITIC_MAP.get(chr));
      } else {
        result.add(chr);
      }
    }
    return String.fromCharArray(result);
  }

Someone has already published a complete solution. You just need to translate this answer from Javascript to Apex. The author of that answer credits this post, which was posted by lehel on May 6, 2011 and archived in 2012. I can't testify to the completeness, but here's the translation:

public class Accents
{
    public static String removeDiacritics(String text)
    {
        for (String letter : patterns.keySet())
            text = text.replaceAll(patterns.get(letter), letter);
        return text;
    }
    static Map<String, String> patterns = new Map<String, String>
    {
        'A' => '[\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F]',
        'AA' => '[\uA732]',
        'AE' => '[\u00C6\u01FC\u01E2]',
        'AO' => '[\uA734]',
        'AU' => '[\uA736]',
        'AV' => '[\uA738\uA73A]',
        'AY' => '[\uA73C]',
        'B' => '[\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181]',
        'C' => '[\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E]',
        'D' => '[\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779]',
        'DZ' => '[\u01F1\u01C4]',
        'Dz' => '[\u01F2\u01C5]',
        'E' => '[\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E]',
        'F' => '[\u0046\u24BB\uFF26\u1E1E\u0191\uA77B]',
        'G' => '[\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E]',
        'H' => '[\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D]',
        'I' => '[\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197]',
        'J' => '[\u004A\u24BF\uFF2A\u0134\u0248]',
        'K' => '[\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2]',
        'L' => '[\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780]',
        'LJ' => '[\u01C7]',
        'Lj' => '[\u01C8]',
        'M' => '[\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C]',
        'N' => '[\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4]',
        'NJ' => '[\u01CA]',
        'Nj' => '[\u01CB]',
        'O' => '[\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C]',
        'OI' => '[\u01A2]',
        'OO' => '[\uA74E]',
        'OU' => '[\u0222]',
        'P' => '[\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754]',
        'Q' => '[\u0051\u24C6\uFF31\uA756\uA758\u024A]',
        'R' => '[\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782]',
        'S' => '[\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784]',
        'T' => '[\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786]',
        'TZ' => '[\uA728]',
        'U' => '[\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244]',
        'V' => '[\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245]',
        'VY' => '[\uA760]',
        'W' => '[\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72]',
        'X' => '[\u0058\u24CD\uFF38\u1E8A\u1E8C]',
        'Y' => '[\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE]',
        'Z' => '[\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762]',
        'a' => '[\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250]',
        'aa' => '[\uA733]',
        'ae' => '[\u00E6\u01FD\u01E3]',
        'ao' => '[\uA735]',
        'au' => '[\uA737]',
        'av' => '[\uA739\uA73B]',
        'ay' => '[\uA73D]',
        'b' => '[\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253]',
        'c' => '[\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184]',
        'd' => '[\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A]',
        'dz' => '[\u01F3\u01C6]',
        'e' => '[\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD]',
        'f' => '[\u0066\u24D5\uFF46\u1E1F\u0192\uA77C]',
        'g' => '[\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F]',
        'h' => '[\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265]',
        'hv' => '[\u0195]',
        'i' => '[\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131]',
        'j' => '[\u006A\u24D9\uFF4A\u0135\u01F0\u0249]',
        'k' => '[\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3]',
        'l' => '[\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747]',
        'lj' => '[\u01C9]',
        'm' => '[\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F]',
        'n' => '[\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5]',
        'nj' => '[\u01CC]',
        'o' => '[\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275]',
        'oi' => '[\u01A3]',
        'ou' => '[\u0223]',
        'oo' => '[\uA74F]',
        'p' => '[\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755]',
        'q' => '[\u0071\u24E0\uFF51\u024B\uA757\uA759]',
        'r' => '[\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783]',
        's' => '[\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B]',
        't' => '[\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787]',
        'tz' => '[\uA729]',
        'u' => '[\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289]',
        'v' => '[\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C]',
        'vy' => '[\uA761]',
        'w' => '[\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73]',
        'x' => '[\u0078\u24E7\uFF58\u1E8B\u1E8D]',
        'y' => '[\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF]',
        'z' => '[\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763]'
    };
}

It sure does work with your desired input/output combo:

system.assertEquals('Hello', Accents.removeDiacritics('Ḧéļḻṏ'));

PS

This approach is painfully slow, taking approximately 1.8ms per execution. I would avoid using it in a loop where you may attempt to "clean" more than 1000 strings.

PPS

You can't compile this class in Execute Anonymous, but it will save in a top-level class. I guess there may be a limit to how many map keys you can specify in a literal constructor using Execute Anonymous, but I haven't isolated the cause of the error.

PPPS

As noted by Charles, you can take this concept and greatly increase performance by taking advantage of the getChars and fromCharArray methods. If you map each Unicode character catalogued below to the corresponding letter, it's about ten times faster.


There's no simple transform method built-in to the library. If you wanted to take the time to map them all out, it would be possible to use a long series of String.replaceAll to manually go through the process, something like:

myString = myString.replaceAll('[ÀÁÂÃÄÅ]','A');
myString = myString.replaceAll('[àáâãäå]','a');
// ....

This would undoubtedly be particularly painful, but it could be possible.