In a previous post we reviewed the Type Helper Code Unit and its collection of useful procedures. There are several other helper code units, and this week we will review the String Conversion Management Code Unit.
If you haven’t seen the post about the Type Helper, you can find it here:
This particular helper stems from the .NET System.Text objects.
StringConManager: Codeunit "StringConversionManagement"
Much smaller than the Type Helper, this code unit clocks in at a tidy 4 procedures. Don’t dismiss it because of the smaller size, these procedures would be rather difficult to do in just AL.
1. WindowsToASCII(InText: Text): Text
Converts a string from Windows encoding to ASCII, replacing non-ASCII characters with their closest ASCII equivalents.
2. GetPaddedString(StringToModify: Text[250]; PadLength: Integer; PadCharacter: Text[1]; Justification: Option Right,Left): Text[250]
Pads a string to a specified length with a given character, either left- or right-justified.
3. RemoveDecimalFromString(StringToModify: Text[250]; PadLength: Integer; PadCharacter: Text[1]; Justification: Option Right,Left): Text[250]
Removes all non-numeric characters except the decimal point from a string, then pads the result as specified.
4. RemoveNonAlphaNumericCharacters(InputString: Text): Text
Removes all non-alphanumeric characters (including underscores) from a string using a regular expression.
These are great, but a little difficult to build a meaningful demo around. They all do what they say on the description. Having awareness that they exist is a great start, and you can always come back here for details.
More details on the Microsoft Learn page: Codeunit StringConversionManagement | Microsoft Learn





Leave a comment