nsITextToSubURI.idl 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. %{C++
  7. // {8B042E22-6F87-11d3-B3C8-00805F8A6670}
  8. #define NS_TEXTTOSUBURI_CID { 0x8b042e22, 0x6f87, 0x11d3, { 0xb3, 0xc8, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
  9. #define NS_ITEXTTOSUBURI_CONTRACTID "@mozilla.org/intl/texttosuburi;1"
  10. %}
  11. [scriptable, uuid(8B042E24-6F87-11d3-B3C8-00805F8A6670)]
  12. interface nsITextToSubURI : nsISupports
  13. {
  14. string ConvertAndEscape(in string charset, in wstring text);
  15. wstring UnEscapeAndConvert(in string charset, in string text);
  16. /**
  17. * Unescapes the given URI fragment (for UI purpose only)
  18. * Note:
  19. * <ul>
  20. * <li> escaping back the result (unescaped string) is not guaranteed to
  21. * give the original escaped string
  22. * <li> In case of a conversion error, the URI fragment (escaped) is
  23. * assumed to be in UTF-8 and converted to AString (UTF-16)
  24. * <li> In case of successful conversion any resulting character listed
  25. * in network.IDN.blacklist_chars (except space) is escaped
  26. * <li> Always succeeeds (callers don't need to do error checking)
  27. * </ul>
  28. *
  29. * @param aCharset the charset to convert from
  30. * @param aURIFragment the URI (or URI fragment) to unescape
  31. * @return Unescaped aURIFragment converted to unicode
  32. */
  33. AString unEscapeURIForUI(in ACString aCharset, in AUTF8String aURIFragment);
  34. /**
  35. * Unescapes only non ASCII characters in the given URI fragment
  36. * note: this method assumes the URI as UTF-8 and fallbacks to the given
  37. * charset if the charset is an ASCII superset
  38. *
  39. * @param aCharset the charset to convert from
  40. * @param aURIFragment the URI (or URI fragment) to unescape
  41. * @return Unescaped aURIFragment converted to unicode
  42. * @throws NS_ERROR_UCONV_NOCONV when there is no decoder for aCharset
  43. * or error code of nsIUnicodeDecoder in case of conversion failure
  44. */
  45. AString unEscapeNonAsciiURI(in ACString aCharset, in AUTF8String aURIFragment);
  46. };