BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›StringBuilder

BlitzMax API

  • Introduction

BRL

    Audio

    • Introduction
    • TChannel
    • TSound

    AudioSample

    • Introduction
    • TAudioSample
    • TAudioSampleLoader

    Bank

    • Introduction
    • TBank

    BankStream

    • Introduction
    • TBankStream

    Base64

    • Introduction
    • TBase64

    Blitz

    • Introduction
    • TArrayBoundsException
    • TBlitzException
    • TNullFunctionException
    • TNullMethodException
    • TNullObjectException
    • TOutOfDataException
    • TRuntimeException
  • BRL.BMPLoader
  • Clipboard

    • Introduction
    • TClipboard
    • TClipboardOpts
    • TWin32ClipboardOpts
    • TX11ClipboardOpts
  • BRL.D3D7Max2D
  • BRL.D3D9Max2D
  • BRL.DirectSoundAudio
  • BRL.EndianStream
  • Event

    • Introduction
    • TEvent
  • BRL.EventQueue
  • BRL.FileSystem
  • BRL.FreeAudioAudio
  • BRL.GLGraphics
  • BRL.GLMax2D
  • BRL.GNet
  • BRL.Graphics
  • BRL.Hook
  • IO

    • Introduction
    • MaxIO
  • BRL.JPGLoader
  • BRL.KeyCodes
  • LinkedList

    • Introduction
    • TList
    • TListEnum
    • TLink

    Map

    • Introduction
    • TMap
    • TIntMap
    • TIntKey
    • TPtrMap
    • TPtrKey
    • TStringMap
  • BRL.Math
  • Matrix

    • Introduction
    • SMat2D
    • SMat2F
    • SMat2I
    • SMat3D
    • SMat3F
    • SMat3I
    • SMat4D
    • SMat4F
    • SMat4I

    Max2D

    • Introduction
    • TImage

    MaxLua

    • Introduction
    • TLuaClass
    • TLuaObject
  • BRL.OGGLoader
  • BRL.OpenALAudio
  • ObjectList

    • Introduction
    • TObjectList
    • TObjectListEnumerator
    • TObjectListReverseEnumerator

    Pixmap

    • Introduction
    • TPixmap
    • TPixmapLoader
  • BRL.PNGLoader
  • BRL.PolledInput
  • Quaternion

    • Introduction
    • SQuatD
    • SQuatF
    • SQuatI
  • BRL.RamStream
  • Random

    • Introduction
    • TRandom

    Reflection

    • Introduction
    • TTypeId
    • TMember
    • TConstant
    • TField
    • TGlobal
    • TFunction
    • TMethod
  • BRL.Retro
  • BRL.Socket
  • BRL.SocketStream
  • BRL.StandardIO
  • Stream

    • Introduction
    • TCStream
    • TIO
    • TStream
    • TStreamException
    • TStreamFactory
    • TStreamReadException
    • TStreamWrapper
    • TStreamWriteException

    StringBuilder

    • Introduction
    • TStringBuilder
    • TSplitBuffer
  • BRL.System
  • BRL.SystemDefault
  • BRL.TextStream
  • BRL.TGALoader
  • ThreadPool

    • Introduction
    • TRunnable
    • TThreadPoolExecutor

    Threads

    • Introduction
    • TThread
    • TThreadData
    • TMutex
    • TSemaphore
    • TCondVar

    Timer

    • Introduction
    • TChrono
  • BRL.TimerDefault
  • Vector

    • Introduction
    • SVec2D
    • SVec2F
    • SVec2I
    • SVec3D
    • SVec3F
    • SVec3I
    • SVec4D
    • SVec4F
    • SVec4I

    Volumes

    • Introduction
    • TVolume
  • BRL.WAVLoader

Text

    CSV

    • Introduction
    • TCsvParser
    • TCsvHeader
    • TCsvRow
    • TCsvOptions
    • SCsvColumn

    Format

    • Introduction
    • TFormatter

    Ini

    • Introduction
    • TIni
    • TIniProperty
    • TIniSection

    JConv

    • Introduction
    • TJConv
    • TJConvBuilder
    • TJConvSerializer

    Json

    • Introduction
    • TJSON
    • TJSONObject
    • TJSONString
    • TJSONInteger
    • TJSONReal
    • TJSONBool
    • TJSONArray
    • TJSONNull
    • TJSONError
    • TJSONNumber

    Regex

    • Introduction
    • TRegEx
    • TRegExMatch
    • TRegExOptions
    • TRegExException

    TOML

    • Introduction
    • ETomlNodeType
    • TToml
    • ITomlNode
    • STomlDate
    • STomlDateTime
    • STomlTime
    • TTomlArray
    • TTomlInteger
    • TTomlString
    • TTomlTable
    • TTomlBoolean

    Xml

    • Introduction
    • TxmlDoc
    • TxmlNode
    • TxmlAttribute

MaxGUI

  • MaxGUI.MaxGUI
  • MaxGUI.Drivers
  • MaxGUI.Localization
  • MaxGUI.ProxyGadgets
  • MaxGUI.CocoaMaxGUI
  • MaxGUI.Win32MaxGUIEx

PUB

  • Pub.FreeJoy
  • Pub.FreeProcess
  • Pub.Glad
  • Pub.Glew
  • Joystick

    • Introduction
    • TJoystickDriver
  • Pub.Lua
  • Pub.OpenAL
  • Pub.OpenGLES
  • Pub.xmmintrin
  • Pub.ZLib

Crypto

    Digest

    • Introduction
    • TMessageDigest
    • TDigestRegister
    • TNoSuchAlgorithmException

    Cipher

    • Introduction
    • TCipher
    • TCipherMode
    • Crypto.AESCipher
    • Crypto.AnubisCipher
    • Crypto.BlowfishCipher
    • Crypto.CamelliaCipher
    • Crypto.Cast5Cipher
    • Crypto.DESCipher
    • Crypto.IdeaCipher
    • Crypto.KasumiCipher
    • Crypto.KhazadCipher
    • Crypto.KSeedCipher
    • Crypto.NoekeonCipher
    • Crypto.SerpentCipher
    • Crypto.SkipjackCipher
    • Crypto.TwofishCipher
    • Crypto.XTeaCipher

    CBCMode

    • Introduction
    • TCBCCipherMode

    CFBMode

    • Introduction
    • TCFBCipherMode

    CTRMode

    • Introduction
    • TCTRCipherMode

    ECBMode

    • Introduction
    • TECBCipherMode

    F8Mode

    • Introduction
    • TF8CipherMode

    LRWMode

    • Introduction
    • TLRWCipherMode

    OFBMode

    • Introduction
    • TOFBCipherMode

    XTSMode

    • Introduction
    • TXTSCipherMode

    Blake2BDigest

    • Introduction
    • TBlake2B_512
    • TBlake2B_384
    • TBlake2B_256
    • TBlake2B_160

    CRC32

    • Introduction
    • TCRC32

    MD5Digest

    • Introduction
    • TMD5

    Ripemd320Digest

    • Introduction
    • TRipemd320

    Ripemd356Digest

    • Introduction
    • TRipemd256

    Ripemd160Digest

    • Introduction
    • TRipemd160

    Ripemd128Digest

    • Introduction
    • TRipemd128

    SHA1Digest

    • Introduction
    • TSHA1

    SHA256Digest

    • Introduction
    • TSHA256

    SHA512Digest

    • Introduction
    • TSHA512

    SHA3Digest

    • Introduction
    • TSHA3_512
    • TSHA3_384
    • TSHA3_256
    • TSHA3_224

    TigerDigest

    • Introduction
    • TTiger

    WhirlpoolDigest

    • Introduction
    • TWhirlpool

    Crypto

    • Introduction
    • TCryptoRandom
    • TCryptoSecretBox
    • TCryptoHash
    • TCryptoSign
    • TCryptoKeyExchange
    • TCryptoKey
    • TCryptoHashKey
    • TCryptoSecretBoxKey
    • TCryptoSignature
    • TCryptoExchangeKeyPair
    • TCryptoSessionKeyPair
    • TCryptoNPacket
    • TCryptoKK1Packet
    • TCryptoKK2Packet
    • TCryptoXX1Packet
    • TCryptoXX2Packet
    • TCryptoXX3Packet
    • TCryptoExchangeState
    • TCryptoPWHashMasterKey
    • TCryptoPWHashStoredKey
    • TCryptoPasswordHash

SDL

    SDL

    • Introduction
    • TSDLStream

    SDLSystem

    • Introduction
    • TSDLMultiGesture

    SDLVideo

    • Introduction
    • TSDLDisplay
    • TSDLDisplayMode
    • TSDLGLContext
    • TSDLWindow

    SDLRender

    • Introduction
    • TSDLRenderer
    • TSDLTexture

    SDLTimer

    • Introduction
    • TSDLTimer

    SDLHaptic

    • Introduction
    • TSDLHaptic
    • TSDLHapticCondition
    • TSDLHapticConstant
    • TSDLHapticCustom
    • TSDLHapticDirection
    • TSDLHapticEffect
    • TSDLHapticLeftRight
    • TSDLHapticPeriodic
    • TSDLHapticRamp

    SDLSensor

    • Introduction
    • TSDLSensor
  • SDL.SDLFreeAudio
  • SDL.GLSDLMax2D
  • SDL.GL2SDLMax2D
  • SDL.D3D9SDLMax2D
  • SDLVirtualJoystick

    • Introduction
    • TVirtualJoystick

Steam

    SteamSDK

    • Introduction
    • TSteamClient
    • TSteamUtils
    • TSteamUserStats
    • TSteamFriends
    • TSteamUGC
    • ISteamFriendsListener
    • ISteamUGCListener
    • ISteamUserStatsListener
    • ISteamUtilsListener
    • EItemPreviewType
    • EPersonaChange
    • EPersonaState
    • ERemoteStoragePublishedFileVisibility
    • EUGCMatchingUGCType
    • EUGCQuery
    • EUserRestriction
    • EUserUGCList
    • EWorkshopFileType
Edit

TStringBuilder

A modifiable String.

A string builder provides functionality to efficiently insert, replace, remove, append and reverse. It is an order of magnitude faster to append Strings to a TStringBuilder than it is to append Strings to Strings.

Example

'
' Append some strings, with basic timing comparison.
'
SuperStrict

Framework BRl.StringBuilder
Import brl.standardio

Const iterations:Int = 20000
Local ms:Int, nms:Int

Local sb:TStringBuilder = New TStringBuilder

Print "Appending a sequence of " + iterations + " numbers.."

Local s:String
ms = MilliSecs()
For Local i:Int = 0 Until iterations
    s :+ i + " "
Next
nms = MilliSecs()
Print "String concat : " + (nms - ms) + " ms"
Print "String length = " + s.Length

Print ""

ms = MilliSecs()
For Local i:Int = 0 Until iterations
    sb.Append(i).Append(" ")
Next
nms = MilliSecs()

Print "StringBuilder concat : " + (nms - ms) + " ms"

Print "StringBuilder String length = " + sb.Length()
Print "StringBuilder capacity = " + sb.Capacity()

Constructors

Method New()

Constructs a TStringBuilder with the default capacity.


Method New(initialCapacity:Int)

Constructs a TStringBuilder with a specified initialCapacity.


Method New(Text:String)

Constructs a TStringBuilder initialized to the contents of Text.


Operators

Method Operator[]:Int(index:Int)

Returns the char value in the buffer at the specified index.

The first char value is at index 0, the next at index 1, and so on, as in array indexing. index must be greater than or equal to 0, and less than the length of the buffer.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print Chr(sb[3])
Print Chr(sb[6])


Method Operator []= (index:Int, char:Int)

The character at the specified index is set to char.

index must be greater than or equal to 0, and less than the length of the buffer.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb[3] = Asc("p")
sb[4] = Asc(",")

Print sb.ToString()


Method Operator =:Int (obj:Object)

Returns True if obj is equal to this string builder.


Method Operator =:Int (sb:TStringBuilder)

Returns True if sb is lexicographically equal to this string builder.


Method Operator <>:Int (obj:Object)

Returns True if obj is not equal to this string builder.


Method Operator <>:Int (sb:TStringBuilder)

Returns True if sb is not lexicographically equal to this string builder.


Methods

Method Length:Int()

Returns the length of the string the string builder would create.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.Length() ' 12


Method Capacity:Int()

Returns the total number of characters that the string builder can accommodate before needing to grow.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.Capacity() ' 16


Method SetLength(length:Int)

Sets the length of the string builder.

If the length is less than the current length, the current text will be truncated. Otherwise, the capacity will be increased as necessary, although the actual length of text will remain the same.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb.SetLength(5)

Print sb.ToString()


Method Append:TStringBuilder(value:String)

Appends a String onto the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

sb.Append("Hello")
sb.Append(" ")
sb.Append("World")

Print sb.ToString()


Method AppendByte:TStringBuilder(value:Byte)

Appends a Byte value to the string builder.


Method Append:TStringBuilder(value:Byte)

Appends a Byte value onto the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local bytes:Byte[] = [0, 1, 2, 3, 4, 5]

For Local b:Byte = EachIn bytes
    sb.Append(b).Append(",")
Next

Print sb.ToString()


Method AppendObject:TStringBuilder(obj:Object)

Appends an object onto the string builder.

This generally calls the object's ToString() method. TStringBuilder objects are simply mem-copied.


Method Append:TStringBuilder(obj:Object)

Appends an object onto the string builder.

This generally calls the object's ToString() method. TStringBuilder objects are simply mem-copied.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local t:TMyType = New TMyType

sb.Append(t)

Print sb.ToString()

Type TMyType

    Method ToString:String()
        Return "Hello World!"
    End Method

End Type


Method Append:TStringBuilder(sb:TStringBuilder)

Appends a TStringBuilder onto the string builder.


Method AppendCString:TStringBuilder(chars:Byte Ptr)

Appends a null-terminated C string onto the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder()

Local b:Byte Ptr = "Hello World".ToCString()

sb.AppendCString(b)

MemFree(b)

Print sb.ToString()


Method AppendDouble:TStringBuilder(value:Double)

Appends a Double value to the string builder.


Method Append:TStringBuilder(value:Double)

Appends a Double value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local x:Double = 35.7
Local y:Double = 40.1

sb.Append(x)
sb.Append(", ")
sb.Append(y)

Print sb.ToString()


Method AppendFloat:TStringBuilder(value:Float)

Appends a Float value to the string builder.


Method Append:TStringBuilder(value:Float)

Appends a Float value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local x:Float = 35.7
Local y:Float = 40.1

sb.Append(x)
sb.Append(", ")
sb.Append(y)

Print sb.ToString()


Method AppendInt:TStringBuilder(value:Int)

Appends an Int value to the string builder.


Method Append:TStringBuilder(value:Int)

Appends an Int value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local a:Int = 5
Local b:Int = 6

sb.Append(a).Append(" + ").Append(b)
sb.Append(" = ").Append(a + b)

Print sb.ToString()


Method AppendLong:TStringBuilder(value:Long)

Appends a Long value to the string builder.


Method Append:TStringBuilder(value:Long)

Appends a Long value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local num:Long = 100000000:Long * 9876
sb.Append(num).AppendNewLine()
sb.Append(num * 99)

Print sb.ToString()


Method AppendNewLine:TStringBuilder()

Appends the new line string to the string builder.

The new line string can be altered using SetNewLineText. This might be used to force the output to always use Unix line endings even when on Windows.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

sb.Append("Hello")
sb.AppendNewLine()
sb.AppendNewLine()
sb.Append("World")

Print sb.ToString()


Method AppendNull:TStringBuilder()

Appends the text representing null to the string builder.


Method AppendShort:TStringBuilder(value:Short)

Appends a Short value to the string builder.


Method Append:TStringBuilder(value:Short)

Appends a Short value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local x:Short = 100
Local y:Short = 55

sb.Append(x).Append(", ").Append(y)

Print sb.ToString()


Method AppendUInt:TStringBuilder(value:UInt)

Appends a UInt value to the string builder.


Method Append:TStringBuilder(value:UInt)

Appends a UInt value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local values:UInt[] = [2, 4, 6, 8, 10]

For Local value:UInt = EachIn values
    sb.Append(value).AppendNewLine()
Next

Print sb.ToString()


Method AppendULong:TStringBuilder(value:ULong)

Appends a Ulong value to the string builder.


Method Append:TStringBuilder(value:ULong)

Appends a Ulong value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local a:ULong = 900
Local b:ULong = 7400

sb.Append(a).Append(", ").Append(b)

Print sb.ToString()


Method AppendSizet:TStringBuilder(value:Size_T)

Appends a Size_T value to the string builder.


Method Append:TStringBuilder(value:Size_T)

Appends a Size_T value to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local s:Size_T = 32684

sb.Append(s).Append(" ^ 2 = ")
sb.Append(Size_T(s ^ 2))

Print sb.ToString()


Method AppendUTF8String:TStringBuilder(chars:Byte Ptr)

Appends a null-terminated UTF-8 string onto the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder()

Local b:Byte Ptr = "Привет, мир!".ToUTF8String()

sb.AppendUTF8String(b)

MemFree(b)

Print sb.ToString()


Method AppendShorts:TStringBuilder(shorts:Short Ptr, length:Int)

Appends an array of shorts onto the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local shorts:Short[] = [65, 66, 67, 68, 69, 70]

sb.AppendShorts(shorts, shorts.length)

Print sb.ToString()


Method AppendChar:TStringBuilder(char:Int)

Appends a character of the given char code point to the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder

Local chars:Int[] = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]

For Local c:Int = EachIn chars
    sb.AppendChar(c)
Next

Print sb.ToString()


Method Compare:Int(o:Object) Override

Compares the string builder with another object.

If the other object is a string builder then, the contents of two are compared lexicographically, as determined by the unicode value of each character in order. If there is no difference, then the shorter of the two contents precedes the longer.

If the other object is not a string builder, the standard object comparison is made.


Method Find:Int(subString:String, startIndex:Int = 0)

Finds first occurance of a sub string.

Returns

-1 if subString not found.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("one two three four five six seven")

Print sb.Find("w") ' 5
Print sb.Find("z") ' -1
Print sb.Find("e", 4) ' 11


Method FindLast:Int(subString:String, startIndex:Int = 0)

Finds last occurance of a sub string.

Returns

-1 if subString not found.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("one two three four five six seven")

Print sb.FindLast("w") ' 5
Print sb.FindLast("z") ' -1
Print sb.FindLast("w", 30) ' -1


Method Format:TStringBuilder(formatText:String, value:String)

Appends a String value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:Byte)

Appends a Byte value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:Short)

Appends a Short value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:Int)

Appends a Int value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:UInt)

Appends a UInt value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:Long)

Appends a Long value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:ULong)

Appends a ULong value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:Size_T)

Appends a Size_T value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:Float)

Appends a Float value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Format:TStringBuilder(formatText:String, value:Double)

Appends a Double value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatString:TStringBuilder(formatText:String, value:String)

Appends a String value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatByte:TStringBuilder(formatText:String, value:Byte)

Appends a Byte value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatShort:TStringBuilder(formatText:String, value:Short)

Appends a Short value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatInt:TStringBuilder(formatText:String, value:Int)

Appends a Int value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatUInt:TStringBuilder(formatText:String, value:UInt)

Appends a UInt value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatLong:TStringBuilder(formatText:String, value:Long)

Appends a Long value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatULong:TStringBuilder(formatText:String, value:ULong)

Appends a ULong value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatSizeT:TStringBuilder(formatText:String, value:Size_T)

Appends a Size_T value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatFloat:TStringBuilder(formatText:String, value:Float)

Appends a Float value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method FormatDouble:TStringBuilder(formatText:String, value:Double)

Appends a Double value to the string builder using the specified printf style formatText.

formatText is limited to 256 character bytes. Formatted text is limited to 2048 character bytes.


Method Hash:ULong()

Returns the calculated hash for the content of the string builder.


Method Left:String(length:Int)

Extracts the leftmost characters from the string builder.

This method extracts the left length characters from the builder. If this many characters are not available, the whole builder is returned. Thus the returned string may be shorter than the length requested.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.Left(4)


Method Trim:TStringBuilder()

Removes leading and trailing non-printable characters from the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("  Hello World!~t~t ")

sb.Trim()

Print sb.ToString()


Method Replace:TStringBuilder(subString:String, withString:String)

Replaces all occurances of subString with withString.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb.Replace("o", "0")

Print sb.ToString()


Method StartsWith:Int(subString:String)

Returns true if string starts with subString.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.StartsWith("he")
Print sb.StartsWith("He")


Method EndsWith:Int(subString:String)

Returns true if string ends with subString.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.EndsWith("z")
Print sb.EndsWith("d!")


Method CharAt:Int(index:Int)

Returns the char value in the buffer at the specified index.

The first char value is at index 0, the next at index 1, and so on, as in array indexing. index must be greater than or equal to 0, and less than the length of the buffer.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print Chr(sb.CharAt(3)) ' l
Print Chr(sb.CharAt(6)) ' W


Method Contains:Int(subString:String)

Returns true if string contains subString.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.Contains("z")
Print sb.Contains("Wo")


Method Join:TStringBuilder(bits:String[], buf:TStringBuilder = Null)

Joins bits together by inserting this string builder between each bit.

Optionally accepts a preassigned string builder for populating with the result of the join.

Returns

buf or a new TStringBuilder object of buf is Null.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder(", ")

Local values:String[] = ["one", "two", "three", "four", "five", "six"]

Local joined:TStringBuilder = sb.Join(values)

Print joined.ToString()


Method JoinStrings:TStringBuilder(bits:String[], joiner:String)

Joins bits together by inserting joiner between each bit, appending to the end of this string builder.


Method ToLower:TStringBuilder()

Converts all of the characters in the buffer to lower case.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.ToLower().ToString()


Method ToUpper:TStringBuilder()

Converts all of the characters in the buffer to upper case.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.ToUpper().ToString()


Method LeftAlign:TStringBuilder(length:Int)

Left aligns the buffer, adjusted to the specified length.

If buffer is longer than the specified length, the buffer is shortened to the specified length. If the buffer is shorter than the specified length, spaces are added to the right end of the buffer to produce the appropriate length.


Method RightAlign:TStringBuilder(length:Int)

Right aligns the buffer, adjusted to the specified length.

If buffer is longer than the specified length, the buffer is shortened to the specified length. If the buffer is shorter than the specified length, spaces are added to the left end of the buffer to produce the appropriate length.


Method Remove:TStringBuilder(startIndex:Int, endIndex:Int)

Removes a range of characters from the string builder.

startIndex is the first character to remove. endIndex is the index after the last character to remove.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb.Remove(2, 9)

Print sb.ToString()


Method RemoveCharAt:TStringBuilder(index:Int)

Removes the character at the specified position in the buffer.

The buffer is shortened by one character.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb.RemoveCharAt(4)

Print sb.ToString()


Method Insert:TStringBuilder(offset:Int, value:String)

Inserts text into the string builder at the specified offset.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb.Insert(6, "BlitzMax ")

Print sb.ToString()


Method Reverse:TStringBuilder()

Reverses the characters of the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb.Reverse()

Print sb.ToString()


Method Right:String(length:Int)

Extracts the rightmost characters from the string builder.

This method extracts the right length characters from the builder. If this many characters are not available, the whole builder is returned. Thus the returned string may be shorter than the length requested.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.Right(4)


Method SetCharAt(index:Int, char:Int)

The character at the specified index is set to char.

index must be greater than or equal to 0, and less than the length of the buffer.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

sb.SetCharAt(3, Asc("p"))
sb.SetCharAt(4, Asc(","))

Print sb.ToString()


Method SetNewLineText:TStringBuilder(newLine:String)

Sets the text to be appended when a new line is added.


Method SetNullText:TStringBuilder(nullText:String)

Sets the text to be appended when null is added.


Method Substring:String(beginIndex:Int, endIndex:Int = 0)

Returns a substring of the string builder given the specified indexes.

beginIndex is the first character of the substring. endIndex is the index after the last character of the substring. If endIndex is zero, will return everything from beginIndex until the end of the string builder.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.SubString(6, 11)


Method Split:TSplitBuffer(separator:String)

Creates a split buffer using the specified separator.

The TSplitBuffer can be used to iterate over the split text.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("1,2,3,4,5,6,7,8,9,10")

For Local s:String = EachIn sb.Split(",")
    Print s
Next


Method ToString:String() Override

Converts the string builder to a String.

Example

SuperStrict

Framework BRL.StringBuilder
Import brl.standardio

Local sb:TStringBuilder = New TStringBuilder("Hello World!")

Print sb.ToString()


Method ToUTF8String:Byte Ptr()

Converts the value of the string builder to a UTF-8 formatted Byte sequence.

The resulting Byte Ptr must be freed with MemFree.

Returns

A pointer to a sequence of Bytes, or Null if the string builder is empty.


Method ToWString:Short Ptr()

Converts the value of the string builder to a sequence of Shorts.

The resulting Short Ptr must be freed with MemFree.

Returns

A pointer to a sequence of Shorts, or Null if the string builder is empty.


Functions

Function Create:TStringBuilder(Text:String)

Constructs a TStringBuilder initialized to the contents of the specified string.


← IntroductionTSplitBuffer →
  • Constructors
    • Method New()
    • Method New(initialCapacity:Int)
    • Method New(Text:String)
  • Operators
    • Method Operator[]:Int(index:Int)
    • Method Operator []= (index:Int, char:Int)
    • Method Operator =:Int (obj:Object)
    • Method Operator =:Int (sb:TStringBuilder)
    • Method Operator <>:Int (obj:Object)
    • Method Operator <>:Int (sb:TStringBuilder)
  • Methods
    • Method Length:Int()
    • Method Capacity:Int()
    • Method SetLength(length:Int)
    • Method Append:TStringBuilder(value:String)
    • Method AppendByte:TStringBuilder(value:Byte)
    • Method Append:TStringBuilder(value:Byte)
    • Method AppendObject:TStringBuilder(obj:Object)
    • Method Append:TStringBuilder(obj:Object)
    • Method Append:TStringBuilder(sb:TStringBuilder)
    • Method AppendCString:TStringBuilder(chars:Byte Ptr)
    • Method AppendDouble:TStringBuilder(value:Double)
    • Method Append:TStringBuilder(value:Double)
    • Method AppendFloat:TStringBuilder(value:Float)
    • Method Append:TStringBuilder(value:Float)
    • Method AppendInt:TStringBuilder(value:Int)
    • Method Append:TStringBuilder(value:Int)
    • Method AppendLong:TStringBuilder(value:Long)
    • Method Append:TStringBuilder(value:Long)
    • Method AppendNewLine:TStringBuilder()
    • Method AppendNull:TStringBuilder()
    • Method AppendShort:TStringBuilder(value:Short)
    • Method Append:TStringBuilder(value:Short)
    • Method AppendUInt:TStringBuilder(value:UInt)
    • Method Append:TStringBuilder(value:UInt)
    • Method AppendULong:TStringBuilder(value:ULong)
    • Method Append:TStringBuilder(value:ULong)
    • Method AppendSizet:TStringBuilder(value:Size_T)
    • Method Append:TStringBuilder(value:Size_T)
    • Method AppendUTF8String:TStringBuilder(chars:Byte Ptr)
    • Method AppendShorts:TStringBuilder(shorts:Short Ptr, length:Int)
    • Method AppendChar:TStringBuilder(char:Int)
    • Method Compare:Int(o:Object) Override
    • Method Find:Int(subString:String, startIndex:Int = 0)
    • Method FindLast:Int(subString:String, startIndex:Int = 0)
    • Method Format:TStringBuilder(formatText:String, value:String)
    • Method Format:TStringBuilder(formatText:String, value:Byte)
    • Method Format:TStringBuilder(formatText:String, value:Short)
    • Method Format:TStringBuilder(formatText:String, value:Int)
    • Method Format:TStringBuilder(formatText:String, value:UInt)
    • Method Format:TStringBuilder(formatText:String, value:Long)
    • Method Format:TStringBuilder(formatText:String, value:ULong)
    • Method Format:TStringBuilder(formatText:String, value:Size_T)
    • Method Format:TStringBuilder(formatText:String, value:Float)
    • Method Format:TStringBuilder(formatText:String, value:Double)
    • Method FormatString:TStringBuilder(formatText:String, value:String)
    • Method FormatByte:TStringBuilder(formatText:String, value:Byte)
    • Method FormatShort:TStringBuilder(formatText:String, value:Short)
    • Method FormatInt:TStringBuilder(formatText:String, value:Int)
    • Method FormatUInt:TStringBuilder(formatText:String, value:UInt)
    • Method FormatLong:TStringBuilder(formatText:String, value:Long)
    • Method FormatULong:TStringBuilder(formatText:String, value:ULong)
    • Method FormatSizeT:TStringBuilder(formatText:String, value:Size_T)
    • Method FormatFloat:TStringBuilder(formatText:String, value:Float)
    • Method FormatDouble:TStringBuilder(formatText:String, value:Double)
    • Method Hash:ULong()
    • Method Left:String(length:Int)
    • Method Trim:TStringBuilder()
    • Method Replace:TStringBuilder(subString:String, withString:String)
    • Method StartsWith:Int(subString:String)
    • Method EndsWith:Int(subString:String)
    • Method CharAt:Int(index:Int)
    • Method Contains:Int(subString:String)
    • Method Join:TStringBuilder(bits:String[], buf:TStringBuilder = Null)
    • Method JoinStrings:TStringBuilder(bits:String[], joiner:String)
    • Method ToLower:TStringBuilder()
    • Method ToUpper:TStringBuilder()
    • Method LeftAlign:TStringBuilder(length:Int)
    • Method RightAlign:TStringBuilder(length:Int)
    • Method Remove:TStringBuilder(startIndex:Int, endIndex:Int)
    • Method RemoveCharAt:TStringBuilder(index:Int)
    • Method Insert:TStringBuilder(offset:Int, value:String)
    • Method Reverse:TStringBuilder()
    • Method Right:String(length:Int)
    • Method SetCharAt(index:Int, char:Int)
    • Method SetNewLineText:TStringBuilder(newLine:String)
    • Method SetNullText:TStringBuilder(nullText:String)
    • Method Substring:String(beginIndex:Int, endIndex:Int = 0)
    • Method Split:TSplitBuffer(separator:String)
    • Method ToString:String() Override
    • Method ToUTF8String:Byte Ptr()
    • Method ToWString:Short Ptr()
  • Functions
    • Function Create:TStringBuilder(Text:String)
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson