the complete guide to mozilla/string

by Scott Collins

last modified 8 April 2001

Abstract

This document provides an introduction to the design and use of the string classes in mozilla, detailed information on their implementation and how one may extend them, and answers to frequently asked questions about strings.

contents

A note to potential editors: don't even consider modifying this document with an HTML editor. That would destroy the internal formatting, and make patches unmanagable.


user's guide

Strings in mozilla are a world apart from char*s. If you don't know why they are different, this section is the place for you to start. If you're already familiar with the hierarchy of string classes in mozilla, then you might want to skip ahead to the implementor's guide or the FAQ.

introduction

what is a string?

readable and writable

promises

flat strings

encoding

sharing

using the string classes right; using the right string class

basic string operations

comparison

concatenation

substrings

find and replace

conversions

calling a function that expects a different kind of string

converting between string classes

converting between encodings

selecting the right string class

user string classes

selecting the right string class for a parameter

selecting the right string class for a local variable

selecting the right string class for a member variable

selecting the right string class for a return value

selecting the right string class in IDL

dont's

using string iterators

what is an iterator?

reading iterators and writing iterators

`chunky' iterating for efficiency

copy_string, character sources and sinks

encoding conversion iterators

summary


implementor's guide


frequently asked questions