nsACString str("This is a long sentence"); str.Truncate(9); // The value of str now becomes "This is a"
nsACString empty(""); empty.Truncate(5); // The value of empty now becomes ""In this example, `empty` is initialized with an empty string and then truncated to a length of 5. Since the string is already empty, the resulting value of `empty` remains empty. The nsACString class belongs to the Gecko Package Library, which is a library of code used in the Mozilla Firefox web browser.