michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIInputStream; michael@0: michael@0: %{C++ michael@0: // {0A698C44-3BFF-11d4-9649-00C0CA135B4E} michael@0: #define NS_ISCRIPTABLEUNICODECONVERTER_CID { 0x0A698C44, 0x3BFF, 0x11d4, { 0x96, 0x49, 0x00, 0xC0, 0xCA, 0x13, 0x5B, 0x4E } } michael@0: #define NS_ISCRIPTABLEUNICODECONVERTER_CONTRACTID "@mozilla.org/intl/scriptableunicodeconverter" michael@0: %} michael@0: michael@0: /** michael@0: * This interface is a unicode encoder for use by scripts michael@0: * michael@0: * @created 8/Jun/2000 michael@0: * @author Makoto Kato [m_kato@ga2.so-net.ne.jp] michael@0: */ michael@0: [scriptable, uuid(f36ee324-5c1c-437f-ba10-2b4db7a18031)] michael@0: interface nsIScriptableUnicodeConverter : nsISupports michael@0: { michael@0: /** michael@0: * Converts the data from Unicode to one Charset. michael@0: * Returns the converted string. After converting, Finish should be called michael@0: * and its return value appended to this return value. michael@0: */ michael@0: ACString ConvertFromUnicode(in AString aSrc); michael@0: michael@0: /** michael@0: * Returns the terminator string. michael@0: * Should be called after ConvertFromUnicode() and appended to that michael@0: * function's return value. michael@0: */ michael@0: ACString Finish(); michael@0: michael@0: /** michael@0: * Converts the data from one Charset to Unicode. michael@0: */ michael@0: AString ConvertToUnicode(in ACString aSrc); michael@0: michael@0: /** michael@0: * Converts an array of bytes to a unicode string. michael@0: */ michael@0: AString convertFromByteArray([const,array,size_is(aCount)] in octet aData, michael@0: in unsigned long aCount); michael@0: michael@0: /** michael@0: * Convert a unicode string to an array of bytes. Finish does not need to be michael@0: * called. michael@0: */ michael@0: void convertToByteArray(in AString aString, michael@0: [optional] out unsigned long aLen, michael@0: [array, size_is(aLen),retval] out octet aData); michael@0: michael@0: /** michael@0: * Converts a unicode string to an input stream. The bytes in the stream are michael@0: * encoded according to the charset attribute. michael@0: * The returned stream will be nonblocking. michael@0: */ michael@0: nsIInputStream convertToInputStream(in AString aString); michael@0: michael@0: /** michael@0: * Current character set. michael@0: * michael@0: * @throw NS_ERROR_UCONV_NOCONV michael@0: * The requested charset is not supported. michael@0: */ michael@0: attribute string charset; michael@0: michael@0: /** michael@0: * Internal use michael@0: * michael@0: * When this attribute is set, all charsets may be accessed. michael@0: * When it is not set (the default), charsets with the isInternal flag michael@0: * may not be accessed. michael@0: */ michael@0: attribute boolean isInternal; michael@0: };