0

Looking for a function in Blue Prism to replace non english characters with english characters.

Example:

Input: Andrés Chávez  Output: Andres Chavez

Toto
  • 89,455
  • 62
  • 89
  • 125
James
  • 11
  • 1
  • 4
  • I Tried like Andrzej Kaczor did and worked for me, remember that you have to make code option C# and add a "System.Globalization" in a Initialize page options in a Object Business. And in that Andrzej's code, has two variables, 'input' and 'output', so you may have to create two data items for use in with the code stage Thanks Andrzej. – Rafael Araujo May 21 '20 at 16:57

3 Answers3

2

I have a code prepared just for that :)

That's a C# code, with one input string and one output string. They are conveniently named "input" and "output".

string help = input.Normalize(System.Text.NormalizationForm.FormD);
System.Text.StringBuilder sb = new System.Text.StringBuilder();

for (int i = 0; i < help.Length; i++)
{
    System.Globalization.UnicodeCategory uc = 
System.Globalization.CharUnicodeInfo.GetUnicodeCategory(help[i]);
    if (uc != System.Globalization.UnicodeCategory.NonSpacingMark)
    {
        sb.Append(help[i]);
    }
}

output = sb.ToString().Normalize(System.Text.NormalizationForm.FormC);

That code requires namespace "System.Globalization". It needs to be added into Code Options of your business object. Printscren for your reference.

I hope you'll be able to get that working easy.

Andrzej Kaczor
  • 1,553
  • 1
  • 11
  • 18
  • Thank you. Were you able to use this in the code stage of Blue Prism? – James Jan 10 '18 at 14:55
  • Hi - I was not able to get this to work. Is the best process to run each action from the same object file for can I have a process that uses an action to call this object even though the data collections that are set as input and output are in the process? Currently, I am capturing text from an excel document that I am storing in the process as a data collection where I am trying to use your code to run on this input and output to a new data collection. – James Jan 17 '18 at 17:02
  • 1
    Hi- I have tried your code but am getting numerous errors. Is this the exact version that you used? – Eoin2211 Jun 18 '18 at 14:23
0

thanks to @Andrzej Kaczor from 2020! Code works perfectly. Just make sure that you use C# as language in your Object, you have System.Globalization namespaces imported as shown and you have input/output set in corresponding tabs in your Code stage.

-2

Hey you could just do this. It replaces upper and lower case of some diacritic letters. I know it's not looking pretty. But it does what I want it to do.

textEdit1 = textEdit.Replace("ě","e").Replace("š","s").Replace("ř","r").Replace("č", "c").Replace("ž", "z").Replace("ý", "y").Replace("á", "a").Replace("í", "i").Replace("é", "e").Replace("ň", "n").Replace("ť", "t").Replace("ď", "d").Replace("Ě", "E").Replace("Š", "S").Replace("Č", "C").Replace("Ř", "R").Replace("Ž", "Z").Replace("Ý", "Y").Replace("Á", "A").Replace("Í", "I").Replace("É", "E").Replace("Ň", "N").Replace("Ť", "T").Replace("Ď", "D");

Mach Petr
  • 1
  • 2
  • It doesn't take into account other characters, such as Danish'/Norwegian's Æ, Ø and Å or German's Ä and Ö. – Kristian Oct 01 '18 at 06:50