What is a String?
The answer is fundamentally different depending on the programming language. There are typically three models, and it is important to understand which model applies to your programming language:
- Object -- A string is an object that contains a sequence of characters (in any language -- Japanese, German, English, Polish, etc). The internal representation of the characters is inconsequential. Except for exporting/importing to byte arrays, all string operations may occur without the need to consider character encoding. For example, two strings may be concatenated to produce a third string.
- Null-Terminated Byte Sequence -- A string is a pointer to memory data containing the bytes representing the characters, terminated by a 0 byte. The programming language provides string primitives to operate on strings that are assumed to be a 1-byte per character encoding. Your application is responsible for interpreting the character encoding of the bytes correctly.
- Non-Null-Terminated Byte Sequence -- Same as above, but the programming language provides a "length" property on the primitive string data type.
This tutorial will focus mostly on ASP, VB6, C#, and VB.NET -- i.e. programming languages that use the "object" model for strings.
Next: Strings in Visual Basic 6.0 (part 1)