uCalc API Version: 2.1.3-preview.2 Released: 6/17/2026
Warning
uCalc API Preview Release Notice:The documentation describes the intended behavior of the API. The current preview build contains incomplete features, unoptimized performance, and is subject to breaking changes.
{#}
Product:
Class:
Remarks
Character Literals
Description: A structural directive used to inject specific characters into a pattern or replacement using their ASCII or Unicode numeric code points.
The {#} directive allows for the explicit definition of characters by their numeric values. This is particularly useful for representing characters that are either impossible to type, non-printing (control characters), or potentially ambiguous when viewed as literal text.
Syntax
{#code}: Injects a single character.{#code1#code2#code3...}: Concatenates multiple characters into a single unit.
For example, {#65#66#67} is equivalent to the literal string ABC.
Common Use Cases
- Control Characters: Inserting Null bytes (
{#0}), Tabs ({#9}), or Line Feeds ({#10}). - Extended ASCII/Unicode: Representing symbols or characters outside the standard keyboard set without worrying about file encoding issues.
- Low-Level Protocols: Matching specific binary markers in data streams that use non-textual delimiters.
Behavior in Patterns and Replacements
- In Patterns: It acts as a literal matcher. The engine expects to see the character(s) corresponding to the provided codes at the current position.
- In Replacements: It acts as an injector, placing the characters into the resulting string.
Examples
1. Succinct (Quick Start: Basic ASCII Matching)
Matching the character 'A' (ASCII 65) explicitly and replacing it with a text label.
New(uCalc::Transformer, t)// Match 'A' via its code pointt.FromTo("{#65}", "CHAR_A")wl(t.Transform("A content"))[Expected Output]CHAR_A content
2. Practical (Real World: Cleaning Null-Terminated Data)
Identifying a data string that contains embedded null characters ({#0}) and stripping them out to create clean text.
New(uCalc::Transformer, t)// Match a Null character and remove it (replace with empty string)t.FromTo("{#0}", "")// Data often comes from C-style buffers with trailing or embedded nullsvar(string, raw_data) = "Part1" + "{#0}" + "Part2"wl(t.Transform(raw_data))[Expected Output]Part1Part2
3. Internal Test (Multi-Character Injection)
Verifying that multiple code points can be concatenated within a single set of curly braces.
New(uCalc::Transformer, t)// 72=H, 69=E, 76=L, 79=Ot.FromTo("GREET", "{#72#69#76#76#79}")wl(t.Transform("GREET user"))[Expected Output]HELLO user
Strategy & Critique
- Encoding Reliability: Using
{#}ensures that the transformation logic is independent of the text editor's encoding settings. It provides a deterministic way to target characters that might otherwise look like garbled text in a source file. - Readability Trade-off: While powerful, using
{#}for standard printable characters (like{#65}forA) makes the pattern harder to read. It should be reserved for special characters or specific low-level protocol requirements. - Critique: The ability to chain codes (e.g.,
{#13#10}) makes it very easy to define specific platform-based sequences like CRLF without relying on the internal_newlinevariable logic. - See Also: Refer to Topic 812 (
{@Newline}) and Topic 801 ({@Whitespace}) for higher-level structural matchers.
Examples
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.FromTo("{#97#98#99}", "{#120#121#122}");
// Same as t.FromTo("abc", "xyz")
Console.WriteLine(t.Transform("abc"));
xyz using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.FromTo("{#97#98#99}", "{#120#121#122}"); // Same as t.FromTo("abc", "xyz") Console.WriteLine(t.Transform("abc"));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.FromTo("{#97#98#99}", "{#120#121#122}");
// Same as t.FromTo("abc", "xyz")
cout << t.Transform("abc") << endl;
}
xyz #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.FromTo("{#97#98#99}", "{#120#121#122}"); // Same as t.FromTo("abc", "xyz") cout << t.Transform("abc") << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.FromTo("{#97#98#99}", "{#120#121#122}")
'// Same as t.FromTo("abc", "xyz")
Console.WriteLine(t.Transform("abc"))
End Sub
End Module
xyz Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.FromTo("{#97#98#99}", "{#120#121#122}") '// Same as t.FromTo("abc", "xyz") Console.WriteLine(t.Transform("abc")) End Sub End Module