Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.34 KB

File metadata and controls

43 lines (34 loc) · 1.34 KB

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()