Skip to content

A @safe mutable string builder class for the D programming language, modeled after .NET's System.Text.StringBuilder.

License

Notifications You must be signed in to change notification settings

ellipticbit/phobos.text.stringbuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StringBuilder

A @safe mutable string builder class for the D programming language, modeled after .NET's System.Text.StringBuilder. It provides efficient methods for appending, inserting, removing, and replacing strings, with support for numeric types, wide strings, interpolated expressions, and more.

The purpose of this project is to experiment with various text handling issues that will be encountered during the Phobos 3 development process.

Features

  • All major .NET StringBuilder API methods and properties
  • Fluent interface (methods return StringBuilder)
  • Comprehensive unit tests
  • UTF-8, UTF-16, UTF-32 support
  • Interpolated string support

Usage Examples

Basic Append

import phobos.text.stringbuilder;

auto sb = new StringBuilder();
sb.append("Hello");
sb.append(" ");
sb.append("World");
assert(sb.toString() == "Hello World");

Insert and Remove

sb.clear();
sb.append("Hello World");
sb.insert(5, "Beautiful ");
assert(sb.toString() == "Hello Beautiful World");
sb.remove(5, 9);
assert(sb.toString() == "Hello World");

Replace

sb.replace("World", "Dlang");
assert(sb.toString() == "Hello Dlang");
sb.replace("Dlang", "D", 6, 5);
assert(sb.toString()

About

A @safe mutable string builder class for the D programming language, modeled after .NET's System.Text.StringBuilder.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages