Skip to content

clsStringUtilities

clsStringUtilities is a stateless, Shared-only helper class that cleans text for downstream systems intolerant of unprintable or non-ASCII characters — most notably Crystal Reports and outbound email — by replacing known Word-pasted special characters and stripping/escaping characters outside a safe printable range.

Purpose

  • Replace unprintable or Word-specific special characters (smart quotes, tabs, bullet characters) with plain-ASCII equivalents or spaces so downstream systems such as Crystal Reports do not error on the content (CleanString).
  • Prepare a string for safe inclusion in an email by escaping characters that interfere with mail parsing (quotes, #, &, ?) and URL-encoding line breaks/tabs (CleanForEmail).

Context

  • Namespace: SAIF.Presentation.Web.Core.Utilities
  • Assembly/package: SAIF.Presentation.Web.Core.Infragistics103 (merged into SAIF.BOF.Presentation.Web.Infragistics103 NuGet package)

Public members

Member Signature Purpose
CleanString Shared Function CleanString(inText As String) As String Replaces known Word-pasted characters (tab, smart apostrophe/quotes, round/square bullets) with plain equivalents, then replaces any remaining character outside the printable ASCII range (32–126, plus CR/LF) with a space, to prevent errors in systems like Crystal Reports that are intolerant of unprintable input.
CleanForEmail Shared Function CleanForEmail(intext As String) As String Replaces double quotes with single quotes, removes # and ?, replaces & with "and", and URL-encodes carriage-return/line-feed and tab characters, to make a string safe for inclusion in an outbound email; returns the input unchanged (including Nothing) if intext is Nothing.

Behavioral notes

  • CleanString builds its result with a Text.StringBuilder for performance on potentially long input text*.
  • CleanForEmail depends on HttpContext.Current.Server being available to URL-encode line breaks and tabs, so it is only usable within an active web request context.

Constraints and usage notes

  • All members are Shared; this class holds no instance state.
  • CleanForEmail returns intext unmodified (rather than an empty string) when passed Nothing.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Presentation.Web.Core.Infragistics103\clsStringUtilities.vb