diff --git a/src/as/com/threerings/util/StringUtil.as b/src/as/com/threerings/util/StringUtil.as index e035d26dd..96ef27b66 100644 --- a/src/as/com/threerings/util/StringUtil.as +++ b/src/as/com/threerings/util/StringUtil.as @@ -43,6 +43,32 @@ public class StringUtil return (str.lastIndexOf(substr, 0) == 0); } + /** + * Append 0 or more copies of the padChar String to the input String + * until it is at least the specified length. + */ + public static function pad ( + str :String, length :int, padChar :String = " ") :String + { + while (str.length < length) { + str += padChar; + } + return str; + } + + /** + * Prepend 0 or more copies of the padChar String to the input String + * until it is at least the specified length. + */ + public static function prepad ( + str :String, length :int, padChar :String = " ") :String + { + while (str.length < length) { + str = padChar + str; + } + return str; + } + /** * Utility function that strips whitespace from the ends of a String. */