nsAString 编辑

« XPCOM API Reference

Summary

The nsAString abstract class represents a character string composed of double-byte storage units. This class is typically used to represent Unicode character arrays.

  #include "nsStringAPI.h"

  class nsAString { ... };

Typedefs

char_type [PRUnichar]
Storage unit for this class.
self_type [nsAString]
An alias for the type of this class.
size_type [PRUint32]
Type used to represent the number of double-byte units stored in the string.
index_type [PRUint32]
Type used to represent an offset into the string.

Methods

BeginReading
The BeginReading function returns a const pointer to the first element of the string's internal buffer.
EndReading
The EndReading function returns a const char_type pointer to the element just beyond the last element of the string's internal buffer.
Length
The Length function returns the number of storage units in the string's internal buffer (not including the null-terminator if present).
Assign
The Assign family of functions sets the value of a string's internal buffer.
Replace
The Replace family of functions sets the value of a string's internal buffer.
Append
The Append family of functions appends a value to the end of a string's internal buffer.
Insert
The Insert family of functions inserts a value into a string's internal buffer.
Cut
The Cut function removes a section of the string's internal buffer.

Operators

operator=
This operator is a shortcut for the Assign family of functions.
operator+=
This operator is a shortcut for the Append family of functions.

Remarks

The nsAString class is never instantiated directly. It should be instantiated using a subclass, such as nsEmbedString .

nsAString corresponds to the AString and DOMString XPIDL data types. nsAString by itself does not imply a particular character encoding. That is, it may be used to store UTF-16 characters, UCS-2 characters, or any random double-byte data. The character encoding in use for a particular nsAString instance depends on the context in which it is used. If used with XPIDL, then the character encodings of the corresponding XPIDL data types applies.

nsAString may even hold data with embedded null values. Thus, the length of the data contained in the nsAString should be determined by calling the nsAString::Length method.

The methods defined on nsAString are implemented as inline wrappers around the XPCOM string functions, prefixed with NS_String. See, for example, NS_StringGetData.

See Also

nsAString::Length, EndReading, NS_StringGetData, nsEmbedString

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:121 次

字数:4606

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文