Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 1
    I know this is a very old thread, but this function does not work as expected. It only works if ChangeThese/IntoThese don't contain the same characters. This is because the String.Replace function will replace certain characters multiple times under certain conditions. If you take ChrTran("Alfabet", "ABab12", "21baBA"), you would expect the output to be "2lfbaet". The actual output however is "Alfaaet". The "A" will be replaced by a "2", but later on that "2" will get replaced again with "A". You need to loop through the input string and replace char by char to prevent double replaces. Commented Jan 11, 2017 at 12:44
  • @RiptoR, you appear to have a good point, but not in the way originally intended the routine to work. In the intended usage, I would not have been doing the same letters in both strings, but duly noted. Commented Jan 11, 2017 at 15:20
  • My apologies. I came across this while looking for a .NET equivalent of Python's translate/maketrans functions so I was thinking in terms of how those functions work. Commented Jan 11, 2017 at 16:38