---
title: Clean text for output
summary: "Sanitizes raw text of Word-originated characters and non-printable bytes before it reaches e-mail, reports, or mailto: links."
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics111
reference_type: package
operation_id: OP-CORE-016
trigger: "Called before sending text to e-mail, reports, or mailto: links"
---

# Clean text for output

This operation sanitizes raw text before it is sent to e-mail, reports, or `mailto:` links, replacing Word-originated special characters, stripping non-printable bytes, and (for e-mail-specific use) removing characters that would break a `mailto:` URL.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CORE-016 |
| **Trigger** | Called before sending text to e-mail, reports, or `mailto:` links |
| **Inputs** | Raw text |
| **Outputs** | Sanitized text |
| **Primary components** | `Utilities.clsStringUtilities.CleanString`, `Utilities.clsStringUtilities.CleanForEmail` |
| **Entry point** | `SAIF.Presentation.Web.Core.Infragistics111/clsStringUtilities.vb` |

## Steps

1. `CleanString` replaces the known Word-originated characters — tab (`Chr(9)`) with five spaces, smart apostrophe (`Chr(146)`), smart quotes (`Chr(147)`/`Chr(148)`), round bullet (`Chr(149)`) and square bullet (`ChrW(61607)`) — with plain equivalents. ([BR-CORE-040](../business-rules.md#br-core-040-known-word-originated-characters-smart-quotes-bullets-tabs-are-normalized-before-text-leaves-the-application))
2. It then rebuilds the string, keeping only characters in the printable ASCII range 32–126 plus CR (13) and LF (10), and substituting a space for everything else. ([BR-CORE-041](../business-rules.md#br-core-041-only-printable-ascii-32126-plus-cr-and-lf-survive-cleanstring-all-other-characters-become-spaces))
3. `CleanForEmail` returns `Nothing` unchanged; otherwise it replaces `"` with `'`, removes `#` and `?`, replaces `&` with `and`, and URL-encodes CRLF and tab. ([BR-CORE-042](../business-rules.md#br-core-042-mailto-text-has-and-removed-and-and-crlftab-url-encoded))

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([CleanString / CleanForEmail called]) --> D1{CleanString: Word-originated characters present?}
	D1 -->|Yes| S1[Replace tab/smart-quotes/bullets with plain equivalents]
	D1 -->|No| S2[No replacement needed]
	S1 --> S3[Rebuild string: keep only ASCII 32-126 + CR/LF, else space]
	S2 --> S3
	Start2([CleanForEmail called]) --> D2{Input is Nothing?}
	D2 -->|Yes| R1([Return Nothing unchanged])
	D2 -->|No| S4["Replace with ', remove # and ?, replace & with and"]
	S4 --> S5[URL-encode CRLF and tab]
```

## Failure and edge-case behavior
- `CleanString`'s ASCII-range filter silently discards or replaces any non-ASCII characters (e.g. accented letters, non-Latin scripts) with a space, which may alter meaning for internationalized text.*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `SAIF.Presentation.Web.Core.Infragistics111/clsStringUtilities.vb`
