uCalc API Version: 2.1.3-preview.2 Released: 6/16/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.
StrLength
Method
Product:
Class:
Gets the length, in characters, of the string currently held by the Transformer.
Syntax
Parameters
Return
int
The number of characters in the string.
Remarks
📏 Getting String Length: The Length Property
The @Length property returns the number of characters in the string currently held by the Transformer and available via the @Text property.
⚡ Performance Advantage
This property is highly efficient. It retrieves the length of the internal string buffer without needing to copy the entire string into a new object. This is a significant performance advantage when working with very large documents (megabytes or gigabytes), as you can check the size of the data before deciding whether to perform an expensive transformation or retrieval operation.
@Length vs. StrData
It's important to use @Length in conjunction with StrData when working with raw memory pointers, particularly in C++. StrData returns a pointer to the start of the character buffer, and @Length provides the size of that buffer, allowing for safe, bounded memory operations.
💡 Comparative Analysis
This property is analogous to .Length on a string in C# or .length() on a std::string in C++. However, its context within the Transformer is key.
Before vs. After Transformation: The value of
@Lengthchanges dynamically as you perform transformations that alter the string. You can call@Length()before a Transform and after it to see how the string's size was affected.Integrated Workflow: uCalc's API provides a cohesive environment. You can load a string, check its
@Length, define rules, run a Transform, and then check the new@Length, all using a single Transformer object. This is a more integrated workflow than manually passing strings between different functions in native code.
Examples
StrLength()
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
t.Str("a b c d e f");
t.FromTo("{ a | d }", "xy");
Console.WriteLine(t);
Console.WriteLine($"Length: {t.StrLength()}");
Console.WriteLine("");
Console.WriteLine(t.Transform());
Console.WriteLine($"Length: {t.StrLength()}");
a b c d e f
Length: 11
xy b c xy e f
Length: 13 using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); t.Str("a b c d e f"); t.FromTo("{ a | d }", "xy"); Console.WriteLine(t); Console.WriteLine($"Length: {t.StrLength()}"); Console.WriteLine(""); Console.WriteLine(t.Transform()); Console.WriteLine($"Length: {t.StrLength()}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
t.Str("a b c d e f");
t.FromTo("{ a | d }", "xy");
cout << t << endl;
cout << "Length: " << t.StrLength() << endl;
cout << "" << endl;
cout << t.Transform() << endl;
cout << "Length: " << t.StrLength() << endl;
}
a b c d e f
Length: 11
xy b c xy e f
Length: 13 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); t.Str("a b c d e f"); t.FromTo("{ a | d }", "xy"); cout << t << endl; cout << "Length: " << t.StrLength() << endl; cout << "" << endl; cout << t.Transform() << endl; cout << "Length: " << t.StrLength() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
t.Str("a b c d e f")
t.FromTo("{ a | d }", "xy")
Console.WriteLine(t)
Console.WriteLine($"Length: {t.StrLength()}")
Console.WriteLine("")
Console.WriteLine(t.Transform())
Console.WriteLine($"Length: {t.StrLength()}")
End Sub
End Module
a b c d e f
Length: 11
xy b c xy e f
Length: 13 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() t.Str("a b c d e f") t.FromTo("{ a | d }", "xy") Console.WriteLine(t) Console.WriteLine($"Length: {t.StrLength()}") Console.WriteLine("") Console.WriteLine(t.Transform()) Console.WriteLine($"Length: {t.StrLength()}") End Sub End Module