// create a string with initial content nsAutoString myString("This is a long string that needs to be truncated"); // truncate to 20 characters myString.Truncate(20); // prints "This is a long strin" printf("%s\n", NS_ConvertUTF16toUTF8(myString).get()); // truncate to 10 characters and add a "..." myString.Truncate(10); myString.AppendLiteral("..."); // prints "This is..." printf("%s\n", NS_ConvertUTF16toUTF8(myString).get());In the first example, we create a string and truncate it to 20 characters. In the second example, we truncate it to 10 characters and add an ellipsis to the end. The `nsAString` class is part of the `mozilla::dom` namespace and is included in the Gecko SDK.