nsIScriptableUnicodeConverter 编辑

This legacy API represents binary data using the lower haft of each 16-bit code unit in a JavaScript string. If the other APIs you are reading data from or writing data to don't require you to use this legacy representation, you should use TextDecoder and TextEncoder (available to chrome JavaScript via Components.utils.importGlobalProperties) instead of this API.

intl/uconv/idl/nsIScriptableUConv.idlScriptable This interface is a Unicode encoder for use by scripts. Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

Implemented by: @mozilla.org/intl/scriptableunicodeconverter. To create an instance, use:

var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
                .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);

Method overview

ACString ConvertFromUnicode(in AString aSrc);
ACString Finish();
AString ConvertToUnicode(in ACString aSrc);
AString convertFromByteArray([const,array,size_is(aCount)] in octet aData, in unsigned long aCount);
void convertToByteArray(in AString aString,[optional] out unsigned long aLen,[array, size_is(aLen),retval] out octet aData);
nsIInputStream convertToInputStream(in AString aString);

Attributes

AttributeTypeDescription
charsetstringCurrent character set. Throws NS_ERROR_UCONV_NOCONV if the requested charset is not supported.

Methods

ConvertFromUnicode()

Converts the data from Unicode to one Charset. Returns the converted string. After converting, Finish should be called and its return value appended to this return value.

ACString ConvertFromUnicode(
  in AString aSrc
);

Finish()

Returns the terminator string. Should be called after ConvertFromUnicode() and appended to that function's return value.

ACString Finish();

ConvertToUnicode()

Converts the data from one Charset to Unicode.

AString ConvertToUnicode(
  in ACString aSrc
);

convertFromByteArray()

Converts an array of bytes to a unicode string.

AString convertFromByteArray(
  [const,array,size_is(aCount)] in octet aData,
  in unsigned long aCount
);

convertToByteArray()

Convert a unicode string to an array of bytes. Finish does not need to be called.

void convertToByteArray(in AString aString,
  out unsigned long aLen, Optional
  [array, size_is(aLen),retval] out octet aData
);

convertToInputStream()

Converts a Unicode string to an input stream. The bytes in the stream are encoded according to the charset attribute. The returned stream is non-blocking.

nsIInputStream convertToInputStream(
  in AString aString
);
Parameters
aString
The text to encode to the stream. The text is encoded into the character set specified by the charset attribute.
Return value

An nsIInputStream that will present the text specified in aString as its data.

Examples

See Reading textual data and Writing textual data for examples.

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

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

发布评论

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

词条统计

浏览:25 次

字数:6448

最后编辑:7 年前

编辑次数:0 次

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