[Home]String

HomePage | Recent Changes | Preferences

Showing revision 16
A string (or more formally, a string of characters) in computing is an important datatype? commonly found in many programming languages to represent text. The exact semantics of the datatype vary from language to language but it usually has the core semantics of representing a finite ordered sequence of characters (a group a characters "strung" together, hence the name). It may also refer to strings of datatypes other than characters (such as strings of numbers or vectors). (these also are called lists) In the theory of computation strings are also often called words, and the letters are elements from an arbitrary finite set. (this should not to be confused with the use of word to refer to the contents of a single computer memory address)

Representations

A common representation is an array of characters. The length can be stored implicitly by using a special terminating character (often NUL?) (the programming language C uses this convention), or explicitly (for example by treating the first byte of the string as its length, a convention used in Pascal).

Here is a NUL terminated string stored in a 10 byte buffer. NUL is the name for the character in ASCII which has the numeric value of zero.

x x x x x x x x x x
F R A N K 0 k f f w
x x x x x x x x x x
The above example is how "FRANK" would look in a 10 byte NUL terminated string. Characters after the 0 do not form part of the representation.

Of course, other representations are possible. Using trees and list?s make it easier to insert characters in the middle of the string.

String Processing

Strings are such a useful datatype that several languages have been designed in order to make string processing applications easy to write. Examples include:

Many UNIX utilities perform simple string manipulations and can be used to easily program some powerful string processing algorithms. Files and finite streams may be viewed as strings.


/Talk

HomePage | Recent Changes | Preferences
This page is read-only | View other revisions | View current revision
Edited August 19, 2001 12:37 am by Koyaanis Qatsi (diff)
Search: