intl/uconv/idl/nsIUTF8ConverterService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/uconv/idl/nsIUTF8ConverterService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:expandtab:shiftwidth=4:tabstop=4:
     1.6 + */
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#include "nsISupports.idl"
    1.12 +
    1.13 +[scriptable, uuid(249f52a3-2599-4b00-ba40-0481364831a2)]
    1.14 +interface nsIUTF8ConverterService : nsISupports
    1.15 +{
    1.16 +  /**
    1.17 +   * Ensure that |aString| is encoded in UTF-8.  If not, 
    1.18 +   * convert to UTF-8 assuming it's encoded in |aCharset|
    1.19 +   * and return the converted string in UTF-8.
    1.20 +   *
    1.21 +   * @param aString a string to  ensure its UTF8ness
    1.22 +   * @param aCharset the charset to convert from if |aString| is not in UTF-8
    1.23 +   * @param aSkipCheck determines whether or not to skip 'ASCIIness' and 
    1.24 +   *        'UTF8ness' check. Set this to PR_TRUE only if you suspect that 
    1.25 +   *        aString can be mistaken for ASCII / UTF-8 but is actually NOT 
    1.26 +   *        in ASCII / UTF-8 so that aString has to go through the conversion.
    1.27 +   *        skipping ASCIIness/UTF8ness check.
    1.28 +   *        The most common case is the input is in 7bit non-ASCII charsets
    1.29 +   *        like ISO-2022-JP, HZ or UTF-7 (in its original form or
    1.30 +   *        a modified form used in IMAP folder names).
    1.31 +   * @param aAllowSubstitution when true, allow the decoder to substitute
    1.32 +   *        invalid input sequences by replacement characters (defaults to
    1.33 +   *        true)
    1.34 +   * @return the converted string in UTF-8.
    1.35 +   * @throws NS_ERROR_UCONV_NOCONV when there is no decoder for aCharset
    1.36 +   *         or error code of nsIUnicodeDecoder in case of conversion failure
    1.37 +   */
    1.38 +
    1.39 +    [optional_argc]
    1.40 +    AUTF8String convertStringToUTF8(in ACString aString, 
    1.41 +                                    in string   aCharset,
    1.42 +                                    in boolean  aSkipCheck,
    1.43 +                                    [optional] in boolean aAllowSubstitution);
    1.44 +
    1.45 +/* XXX : To-be-added. convertStringFromUTF8 */
    1.46 +   
    1.47 +  /**
    1.48 +   * Ensure that |aSpec| (after URL-unescaping it) is encoded in UTF-8.  
    1.49 +   * If not,  convert it to UTF-8, assuming it's encoded in |aCharset|,  
    1.50 +   * and return the result.
    1.51 +   *
    1.52 +   * <p>Make sure that all characters outside US-ASCII in your input spec 
    1.53 +   * are url-escaped if  your spec is not in UTF-8 (before url-escaping) 
    1.54 +   * because the presence of non-ASCII characters is <strong>blindly</strong>
    1.55 +   * regarded as an indication that your input spec is in unescaped UTF-8
    1.56 +   * and it will be returned without further processing. No valid spec
    1.57 +   * going around in Mozilla code would break this assumption. 
    1.58 +   *
    1.59 +   * <p>XXX The above may change in the future depending on the usage pattern.
    1.60 +   *
    1.61 +   * @param aSpec an url-escaped URI spec to  ensure its UTF8ness
    1.62 +   * @param aCharset the charset to convert from if |aSpec| is not in UTF-8
    1.63 +   * @return the converted spec in UTF-8.
    1.64 +   * @throws NS_ERROR_UCONV_NOCONV when there is no decoder for aCharset
    1.65 +   *         or error code of nsIUnicodeDecoder in case of conversion failure
    1.66 +   */
    1.67 +
    1.68 +    AUTF8String convertURISpecToUTF8(in ACString aSpec, 
    1.69 +                                     in string   aCharset);
    1.70 +};
    1.71 +

mercurial