« XPCOM API Reference


The BeginReading function returns a const pointer to the first element of the string's internal buffer.

 const char_type* BeginReading() const;


The resulting character array is not necessarily null-terminated. The length of the array is determined by the result of the Length method.

Example Code

  // count the number of times a particular character appears in the string

  PRUint32 CountChar(const nsAString& str, PRUnichar c)
    const PRUnichar* start = str.BeginReading();
    const PRUnichar* end = str.EndReading();

    PRUint32 count = 0;
    while (start != end)
      if (*start++ == c)

    return count;

See Also


Document Tags and Contributors

 Contributors to this page: Sheppy, Pmash
 Last updated by: Sheppy,