//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
//  File: mlang.idl
//
//  Contents: IMultiLanguage interface definition
//
//
//--------------------------------------------------------------------------

cpp_quote("//=--------------------------------------------------------------------------=")
cpp_quote("// MLang.h                                                                    ")
cpp_quote("//=--------------------------------------------------------------------------=")
cpp_quote("// Copyright (c) Microsoft Corporation. All rights reserved.")
cpp_quote("//                                                                            ")
cpp_quote("// THIS CODE AND INFORMATION IS PROVIDED \"AS IS\" WITHOUT WARRANTY OF        ")
cpp_quote("// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO        ")
cpp_quote("// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A             ")
cpp_quote("// PARTICULAR PURPOSE.                                                        ")
cpp_quote("//=--------------------------------------------------------------------------=")
cpp_quote("                                                                              ")
cpp_quote("#pragma comment(lib,\"uuid.lib\")                                             ")
cpp_quote("                                                                              ")
cpp_quote("//----------------------------------------------------------------------------")
cpp_quote("// IMultiLanguage Interfaces.                                                 ")
cpp_quote("                                                                              ")

#ifndef DO_NO_IMPORTS
import "unknwn.idl";
#endif

[
    uuid(275c23e0-3747-11d0-9fea-00aa003f8646),
    helpstring("MultiLanguage Object Model"),
    lcid(0x0000),
    version(0.2)
]
library MultiLanguage
{
    importlib("stdole2.tlb");

    typedef WORD LANGID;

    typedef enum tagMLSTR_FLAGS
    {
        MLSTR_READ                  = 1,
        MLSTR_WRITE                 = 2
    } MLSTR_FLAGS;

    [
        local,
        uuid(D24ACD21-BA72-11D0-B188-00AA0038C969),
        helpstring("IMLangStringBufW Interface"),
        pointer_default(unique)
    ]
    interface IMLangStringBufW : IUnknown
    {
        HRESULT GetStatus([out, annotation("__out_opt")] long* plFlags, [out, annotation("__out_opt")] long* pcchBuf);
        HRESULT LockBuf([in] long cchOffset, [in] long cchMaxLock, [out, size_is(,*pcchBuf), annotation("__deref_out_ecount(*pcchBuf)")] WCHAR** ppszBuf, [out, annotation("__out_opt")] long* pcchBuf);
        HRESULT UnlockBuf([in, size_is(cchWrite - cchOffset), annotation("__in_ecount(cchWrite-cchOffset)")] const WCHAR* pszBuf, [in] long cchOffset, [in] long cchWrite);
        HRESULT Insert([in] long cchOffset, [in] long cchMaxInsert, [out, annotation("__out_opt")] long* pcchActual);
        HRESULT Delete([in] long cchOffset, [in] long cchDelete);
    };

    [
        local,
        uuid(D24ACD23-BA72-11D0-B188-00AA0038C969),
        helpstring("IMLangStringBufA Interface"),
        pointer_default(unique)
    ]
    interface IMLangStringBufA : IUnknown
    {
        HRESULT GetStatus([out, annotation("__out_opt")] long* plFlags, [out, annotation("__out_opt")] long* pcchBuf);
        HRESULT LockBuf([in] long cchOffset, [in] long cchMaxLock, [out, size_is(,*pcchBuf), annotation("__deref_out_ecount(*pcchBuf)")] CHAR** ppszBuf, [out, annotation("__out_opt")] long* pcchBuf);
        HRESULT UnlockBuf([in, size_is(cchWrite - cchOffset), annotation("__in_ecount(cchWrite-cchOffset)")] const CHAR* pszBuf, [in] long cchOffset, [in] long cchWrite);
        HRESULT Insert([in] long cchOffset, [in] long cchMaxInsert, [out, annotation("__out_opt")] long* pcchActual);
        HRESULT Delete([in] long cchOffset, [in] long cchDelete);
    };

    [
        local,
        uuid(C04D65CE-B70D-11D0-B188-00AA0038C969),
        helpstring("IMLangString Interface"),
        pointer_default(unique)
    ]
    interface IMLangString : IUnknown
    {
        HRESULT Sync([in] BOOL fNoAccess);
        HRESULT GetLength([out, retval, annotation("__out_opt")] long* plLen);
        HRESULT SetMLStr([in] long lDestPos, [in] long lDestLen, [in, annotation("__in")] IUnknown* pSrcMLStr, [in] long lSrcPos, [in] long lSrcLen);
        HRESULT GetMLStr([in] long lSrcPos, [in] long lSrcLen, [in, annotation("__in")] IUnknown* pUnkOuter, [in] DWORD dwClsContext, [in, annotation("__in")] const IID* piid, [out, annotation("__deref_out")] IUnknown** ppDestMLStr, [out, annotation("__out_opt")] long* plDestPos, [out, annotation("__out_opt")] long* plDestLen);
    };

    [
        local,
        uuid(C04D65D0-B70D-11D0-B188-00AA0038C969),
        helpstring("IMLangStringWStr Interface"),
        pointer_default(unique)
    ]
    interface IMLangStringWStr : IMLangString
    {
        HRESULT SetWStr([in] long lDestPos, [in] long lDestLen, [in, string, size_is(cchSrc), annotation("__in_ecount(cchSrc)")] LPCWSTR pszSrc, [in] long cchSrc, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT SetStrBufW([in] long lDestPos, [in] long lDestLen, [in, unique, annotation("__in_opt")] IMLangStringBufW* pSrcBuf, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT GetWStr([in] long lSrcPos, [in] long lSrcLen, [out, size_is(cchDest), annotation("__out_ecount_opt(cchDest)")] LPWSTR pszDest, [in] long cchDest, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT GetStrBufW([in] long lSrcPos, [in] long lSrcMaxLen, [out, annotation("__deref_out")] IMLangStringBufW** ppDestBuf, [out, annotation("__out_opt")] long* plDestLen);
        HRESULT LockWStr([in] long lSrcPos, [in] long lSrcLen, [in] long lFlags, [in] long cchRequest, [out, size_is(,*pcchDest), annotation("__deref_opt_out_ecount(*pcchDest)")] LPWSTR* ppszDest, [out, annotation("__out_opt")] long* pcchDest, [out, annotation("__out_opt")] long* plDestLen);
        HRESULT UnlockWStr([in, string, size_is(cchSrc), annotation("__in_ecount(cchSrc)")] LPCWSTR pszSrc, [in] long cchSrc, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT SetLocale([in] long lDestPos, [in] long lDestLen, [in] LCID locale);
        HRESULT GetLocale([in] long lSrcPos, [in] long lSrcMaxLen, [out, annotation("__out_opt")] LCID* plocale, [out, annotation("__out_opt")] long* plLocalePos, [out, annotation("__out_opt")] long* plLocaleLen);
    };

    [
        local,
        uuid(C04D65D2-B70D-11D0-B188-00AA0038C969),
        helpstring("IMLangStringAStr Interface"),
        pointer_default(unique)
    ]
    interface IMLangStringAStr : IMLangString
    {
        HRESULT SetAStr([in] long lDestPos, [in] long lDestLen, [in] UINT uCodePage, [in, size_is(cchSrc), annotation("__in_ecount(cchSrc)")] LPCSTR pszSrc, [in] long cchSrc, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT SetStrBufA([in] long lDestPos, [in] long lDestLen, [in] UINT uCodePage, [in, annotation("__in_opt")] IMLangStringBufA* pSrcBuf, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT GetAStr([in] long lSrcPos, [in] long lSrcLen, [in] UINT uCodePageIn, [out, annotation("__reserved")] UINT* puCodePageOut, [out, size_is(cchDest), annotation("__out_ecount_opt(cchDest)")] LPSTR pszDest, [in] long cchDest, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT GetStrBufA([in] long lSrcPos, [in] long lSrcMaxLen, [out, annotation("__out_opt")] UINT* puDestCodePage, [out, annotation("__deref_out")] IMLangStringBufA** ppDestBuf, [out, annotation("__out_opt")] long* plDestLen);
        HRESULT LockAStr([in] long lSrcPos, [in] long lSrcLen, [in] long lFlags, [in] UINT uCodePageIn, [in] long cchRequest, [out, annotation("__out_opt")] UINT* puCodePageOut, [out, size_is(,*pcchDest), annotation("__deref_opt_out_ecount(*pcchDest)")] LPSTR* ppszDest, [out, annotation("__out_opt")] long* pcchDest, [out, annotation("__out_opt")] long* plDestLen);
        HRESULT UnlockAStr([in, size_is(cchSrc), annotation("__in_ecount(cchSrc)")] LPCSTR pszSrc, [in] long cchSrc, [out, annotation("__out_opt")] long* pcchActual, [out, annotation("__out_opt")] long* plActualLen);
        HRESULT SetLocale([in] long lDestPos, [in] long lDestLen, [in] LCID locale);
        HRESULT GetLocale([in] long lSrcPos, [in] long lSrcMaxLen, [out, annotation("__out_opt")] LCID* plocale, [out, annotation("__out_opt")] long* plLocalePos, [out, annotation("__out_opt")] long* plLocaleLen);
    };

    [
        uuid(C04D65CF-B70D-11D0-B188-00AA0038C969),
        helpstring("MLangString Class")
    ]
    coclass CMLangString
    {
        [default] interface IMLangString;
        interface IMLangStringWStr;
        interface IMLangStringAStr;
    };

    [
        uuid(F5BE2EE1-BFD7-11D0-B188-00AA0038C969),
        helpstring("IMLangLineBreakConsole Interface"),
        pointer_default(unique),
        local
    ]
    interface IMLangLineBreakConsole : IUnknown
    {
        [helpstring("method BreakLineML")] HRESULT BreakLineML([in, annotation("__in")] IMLangString* pSrcMLStr, [in] long lSrcPos, [in] long lSrcLen, [in] long cMinColumns, [in] long cMaxColumns, [out, annotation("__out_opt")] long* plLineLen, [out, annotation("__out_opt")] long* plSkipLen);
        [helpstring("method BreakLineW")] HRESULT BreakLineW([in] LCID locale, [in, size_is(cchSrc), annotation("__in_ecount(cchSrc)")] const WCHAR* pszSrc, [in] long cchSrc, [in] long cMaxColumns, [out, annotation("__out_opt")] long* pcchLine, [out, annotation("__out_opt")] long* pcchSkip);
        [helpstring("method BreakLineA")] HRESULT BreakLineA([in] LCID locale, [in] UINT uCodePage, [in, size_is(cchSrc), annotation("__in_ecount(cchSrc)")] const CHAR* pszSrc, [in] long cchSrc, [in] long cMaxColumns, [out, annotation("__out_opt")] long* pcchLine, [out, annotation("__out_opt")] long* pcchSkip);
    };

    [
        object,
        uuid(275c23e3-3747-11d0-9fea-00aa003f8646),
        pointer_default(unique),
        local
    ]
    interface IEnumCodePage : IUnknown
    {
        const USHORT MAX_MIMECP_NAME    = 64;
        const USHORT MAX_MIMECSET_NAME  = 50;
        const USHORT MAX_MIMEFACE_NAME  = 32;

        typedef enum tagMIMECONTF
        {
            MIMECONTF_MAILNEWS          = 0x00000001,
            MIMECONTF_BROWSER           = 0x00000002,
            MIMECONTF_MINIMAL           = 0x00000004,
            MIMECONTF_IMPORT            = 0x00000008,
            MIMECONTF_SAVABLE_MAILNEWS  = 0x00000100,
            MIMECONTF_SAVABLE_BROWSER   = 0x00000200,
            MIMECONTF_EXPORT            = 0x00000400,
            MIMECONTF_PRIVCONVERTER     = 0x00010000,
            MIMECONTF_VALID             = 0x00020000,
            MIMECONTF_VALID_NLS         = 0x00040000,
            MIMECONTF_MIME_IE4          = 0x10000000,
            MIMECONTF_MIME_LATEST       = 0x20000000,
            MIMECONTF_MIME_REGISTRY     = 0x40000000
        } MIMECONTF;

        typedef struct tagMIMECPINFO
        {
            DWORD   dwFlags;
            UINT    uiCodePage;
            UINT    uiFamilyCodePage;
            WCHAR   wszDescription[MAX_MIMECP_NAME];
            WCHAR   wszWebCharset[MAX_MIMECSET_NAME];
            WCHAR   wszHeaderCharset[MAX_MIMECSET_NAME];
            WCHAR   wszBodyCharset[MAX_MIMECSET_NAME];
            WCHAR   wszFixedWidthFont[MAX_MIMEFACE_NAME];
            WCHAR   wszProportionalFont[MAX_MIMEFACE_NAME];
            BYTE    bGDICharset;
        } MIMECPINFO, *PMIMECPINFO;

        typedef struct tagMIMECSETINFO
        {
            UINT    uiCodePage;
            UINT    uiInternetEncoding;
            WCHAR   wszCharset[MAX_MIMECSET_NAME];
        } MIMECSETINFO, *PMIMECSETINFO;

        typedef [unique] IEnumCodePage *LPENUMCODEPAGE;

        HRESULT Clone
        (
            [out, annotation("__reserved")] IEnumCodePage **ppEnum
        );

        HRESULT Next
        (
            [in]  ULONG                             celt,
            [out, annotation("__out")] PMIMECPINFO  rgelt,
            [out, annotation("__out_opt")] ULONG    *pceltFetched
        );

        HRESULT Reset();

        HRESULT Skip
        (
            [in]  ULONG         celt
        );
    };

    [
        object,
        uuid(3dc39d1d-c030-11d0-b81b-00c04fc9b31f),
        pointer_default(unique),
        local
    ]
    interface IEnumRfc1766 : IUnknown
    {
        const USHORT MAX_RFC1766_NAME   = 6;
        const USHORT MAX_LOCALE_NAME    = 32;

        typedef struct tagRFC1766INFO
        {
            LCID    lcid;
            WCHAR   wszRfc1766[MAX_RFC1766_NAME];
            WCHAR   wszLocaleName[MAX_LOCALE_NAME];
        } RFC1766INFO, *PRFC1766INFO;

        typedef [unique] IEnumRfc1766 *LPENUMRFC1766;

        HRESULT Clone
        (
            [out, annotation("__reserved")] IEnumRfc1766 **ppEnum
        );

        HRESULT Next
        (
            [in]  ULONG                             celt,
            [out, annotation("__out")] PRFC1766INFO rgelt,
            [out, annotation("__out_opt")] ULONG    *pceltFetched
        );

        HRESULT Reset();

        HRESULT Skip
        (
            [in]  ULONG         celt
        );
    };

    [
        object,
        uuid(AE5F1430-388B-11d2-8380-00C04F8F5DA1),
        pointer_default(unique),
        local
    ]
    interface IEnumScript : IUnknown
    {
        const USHORT MAX_SCRIPT_NAME    = 48;
        typedef BYTE    SCRIPT_ID;
        typedef __int64 SCRIPT_IDS;


        typedef enum tagSCRIPTCONTF
        {
            sidDefault,          // 0
            sidMerge,            // 1
            sidAsciiSym,         // 2
            sidAsciiLatin,       // 3
            sidLatin,            // 4
            sidGreek,            // 5
            sidCyrillic,         // 6
            sidArmenian,         // 7
            sidHebrew,           // 8
            sidArabic,           // 9
            sidDevanagari,       // 10
            sidBengali,          // 11
            sidGurmukhi,         // 12
            sidGujarati,         // 13
            sidOriya,            // 14
            sidTamil,            // 15
            sidTelugu,           // 16
            sidKannada,          // 17
            sidMalayalam,        // 18
            sidThai,             // 19
            sidLao,              // 20
            sidTibetan,          // 21
            sidGeorgian,         // 22
            sidHangul,           // 23
            sidKana,             // 24
            sidBopomofo,         // 25
            sidHan,              // 26
            sidEthiopic,         // 27
            sidCanSyllabic,      // 28
            sidCherokee,         // 29
            sidYi,               // 30
            sidBraille,          // 31
            sidRunic,            // 32
            sidOgham,            // 33
            sidSinhala,          // 34
            sidSyriac,           // 35
            sidBurmese,          // 36
            sidKhmer,            // 37
            sidThaana,           // 38
            sidMongolian,        // 39
            sidUserDefined,      // 40
            sidLim,              // 41
            sidFEFirst = sidHangul,
            sidFELast = sidHan
        } SCRIPTCONTF;

        typedef struct tagSCRIPTINFO
        {
            SCRIPT_ID   ScriptId;
            UINT        uiCodePage;                         
            WCHAR       wszDescription[MAX_SCRIPT_NAME];    
            WCHAR       wszFixedWidthFont[MAX_MIMEFACE_NAME];
            WCHAR       wszProportionalFont[MAX_MIMEFACE_NAME];
        } SCRIPTINFO, *PSCRIPTINFO;


        typedef [unique] IEnumScript *LPENUMScript;

        HRESULT Clone
        (
            [out, annotation("__reserved")] IEnumScript **ppEnum
        );

        HRESULT Next
        (
            [in]  ULONG                             celt,
            [out, annotation("__out")] PSCRIPTINFO  rgelt,
            [out, annotation("__out_opt")] ULONG    *pceltFetched
        );

        HRESULT Reset();

        HRESULT Skip
        (
            [in]  ULONG         celt
        );
    };



    [
        object,
        uuid(d66d6f98-cdaa-11d0-b822-00c04fc9b31f),
        pointer_default(unique),
        local
    ]
    interface IMLangConvertCharset : IUnknown
    {
        typedef enum tagMLCONVCHARF
        {
            MLCONVCHARF_AUTODETECT      = 1,
            MLCONVCHARF_ENTITIZE        = 2,
            MLCONVCHARF_NCR_ENTITIZE    = 2,
            MLCONVCHARF_NAME_ENTITIZE   = 4,
            MLCONVCHARF_USEDEFCHAR      = 8,
            MLCONVCHARF_NOBESTFITCHARS  = 16,
            MLCONVCHARF_DETECTJPN       = 32
        } MLCONVCHAR;

        typedef enum tagMLCPF
        {
            MLDETECTF_MAILNEWS          = 0x0001, // Outgoing encoding for mail client
            MLDETECTF_BROWSER           = 0x0002, // Outgoing encoding for browser client
            MLDETECTF_VALID             = 0x0004, // Detection result must be valid for conversion and text rendering
            MLDETECTF_VALID_NLS         = 0x0008, // Detection result must be valid for conversion
            MLDETECTF_PRESERVE_ORDER    = 0x0010, // Perserve perferred code page order
            MLDETECTF_PREFERRED_ONLY    = 0x0020, // Only return one of preferred code pages as detection result
            MLDETECTF_FILTER_SPECIALCHAR= 0x0040, // Filter out graphical symbols and punctuations
            MLDETECTF_EURO_UTF8         = 0x0080, // Force dection result to be UTF8 when EURO character encountered
        } MLCP;

        typedef [unique] IMLangConvertCharset *LPMLANGCONVERTCHARSET;

        HRESULT Initialize
        (
            [in]  UINT  uiSrcCodePage,
            [in]  UINT  uiDstCodePage,
            [in]  DWORD dwProperty
        );

        HRESULT GetSourceCodePage
        (
            [out, annotation("__out")] UINT  *puiSrcCodePage
        );

        HRESULT GetDestinationCodePage
        (
            [out, annotation("__out")] UINT  *puiDstCodePage
        );

        HRESULT GetProperty
        (
            [out, annotation("__out")] DWORD *pdwProperty
        );

        HRESULT DoConversion
        (
            [in, annotation("__in_bcount(*pcSrcSize)")]  BYTE    *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT            *pcSrcSize,
            [out, annotation("__out_bcount(*pcDstSize)")]  BYTE  *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT            *pcDstSize
        );

        HRESULT DoConversionToUnicode
        (
            [in, annotation("__in_bcount(*pcSrcSize)")]  CHAR    *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT            *pcSrcSize,
            [out, annotation("__out_ecount(*pcDstSize)")]  WCHAR *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT            *pcDstSize
        );

        HRESULT DoConversionFromUnicode
        (
            [in, annotation("__in_ecount(*pcSrcSize)")]  WCHAR  *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT           *pcSrcSize,
            [out, annotation("__out_bcount(*pcDstSize)")]  CHAR *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT           *pcDstSize
        );

    };

    [
      uuid(d66d6f99-cdaa-11d0-b822-00c04fc9b31f),
    ]
    coclass CMLangConvertCharset
    {
        [default] interface IMLangConvertCharset;
    };

    [
        object,
        uuid(275c23e1-3747-11d0-9fea-00aa003f8646),
        pointer_default(unique),
        local
    ]
    interface IMultiLanguage : IUnknown
    {
        typedef [unique] IMultiLanguage *LPMULTILANGUAGE;

        HRESULT GetNumberOfCodePageInfo
        (
            [out, annotation("__out")] UINT  *pcCodePage
        );

        HRESULT GetCodePageInfo
        (
            [in]  UINT                              uiCodePage,
            [out, annotation("__out")] PMIMECPINFO  pCodePageInfo
        );

        HRESULT GetFamilyCodePage
        (
            [in]  UINT                              uiCodePage,
            [out, annotation("__out")] UINT         *puiFamilyCodePage
        );

        HRESULT EnumCodePages
        (
            [in]  DWORD                                     grfFlags,
            [out, annotation("__deref_out")] IEnumCodePage  **ppEnumCodePage
        );

        HRESULT GetCharsetInfo
        (
            [in]  BSTR                                  Charset,
            [out, annotation("__out")] PMIMECSETINFO    pCharsetInfo
        );

        HRESULT IsConvertible
        (
            [in]  DWORD         dwSrcEncoding,
            [in]  DWORD         dwDstEncoding
        );

        HRESULT ConvertString
        (
            [in,out, annotation("__inout_opt")]  DWORD              *pdwMode,
            [in]  DWORD                                             dwSrcEncoding,
            [in]  DWORD                                             dwDstEncoding,
            [in, annotation("__in_bcount_opt(*pcSrcSize)")]  BYTE   *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcSrcSize,
            [out, annotation("__out_bcount_opt(*pcDstSize)")]  BYTE *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcDstSize
        );

        HRESULT ConvertStringToUnicode
        (
            [in,out, annotation("__inout_opt")]  DWORD                  *pdwMode,
            [in]  DWORD                                                 dwEncoding,
            [in, annotation("__in_bcount_opt(*pcSrcSize)")]  CHAR       *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT                   *pcSrcSize,
            [out, annotation("__out_ecount_opt(*pcDstSize)")]  WCHAR    *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT                   *pcDstSize
        );

        HRESULT ConvertStringFromUnicode
        (
            [in,out, annotation("__inout_opt")]  DWORD                  *pdwMode,
            [in]  DWORD                                                 dwEncoding,
            [in, annotation("__in_ecount_opt(*pcSrcSize)")]  WCHAR      *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT                   *pcSrcSize,
            [out, annotation("__out_bcount_opt(*pcDstSize)")]  CHAR     *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT                   *pcDstSize
        );

        HRESULT ConvertStringReset();

        HRESULT GetRfc1766FromLcid
        (
            [in]  LCID                              Locale,
            [out, annotation("__deref_out")] BSTR   *pbstrRfc1766
        );

        HRESULT GetLcidFromRfc1766
        (
            [out, annotation("__out")] LCID *pLocale,
            [in, annotation("__in")]  BSTR  bstrRfc1766
        );

        HRESULT EnumRfc1766
        (
            [out, annotation("__deref_out")] IEnumRfc1766 **ppEnumRfc1766
        );

        HRESULT GetRfc1766Info
        (
            [in]  LCID                              Locale,
            [out, annotation("__out")] PRFC1766INFO pRfc1766Info
        );

        HRESULT CreateConvertCharset
        (
            [in]  UINT                                              uiSrcCodePage,
            [in]  UINT                                              uiDstCodePage,
            [in]  DWORD                                             dwProperty,
            [out, annotation("__deref_out")] IMLangConvertCharset   **ppMLangConvertCharset
        );

    };

cpp_quote("// dwfIODControl definitions for ValidateCodePageEx()")
cpp_quote("#define CPIOD_PEEK          0x40000000L")
cpp_quote("#define CPIOD_FORCE_PROMPT  0x80000000L")

    [
        object,
        uuid(DCCFC164-2B38-11d2-B7EC-00C04F8F5D9A),
        pointer_default(unique),
        local
    ]
    interface IMultiLanguage2 : IUnknown
    {
        typedef [unique] IMultiLanguage2 *LPMULTILANGUAGE2;

        typedef enum tagMLDETECTCP
        {
            MLDETECTCP_NONE     = 0,
            MLDETECTCP_7BIT     = 1,
            MLDETECTCP_8BIT     = 2,
            MLDETECTCP_DBCS     = 4,
            MLDETECTCP_HTML     = 8,
            MLDETECTCP_NUMBER   = 16
        } MLDETECTCP ;

        typedef struct tagDetectEncodingInfo
        {
            UINT     nLangID;            // Win32 primary language ID
            UINT     nCodePage;          // Win32 code page (valid for SBCS and DBCS input only!)
            INT     nDocPercent;        // % of doc in this language, 0-100
            INT     nConfidence;        // Relative confidence measure, approx 0-100
        } DetectEncodingInfo, *pDetectEncodingInfo;


        typedef enum tagSCRIPTFONTCONTF
        {
            SCRIPTCONTF_FIXED_FONT          = 0x00000001,
            SCRIPTCONTF_PROPORTIONAL_FONT   = 0x00000002,
            SCRIPTCONTF_SCRIPT_USER     = 0x00010000,
            SCRIPTCONTF_SCRIPT_HIDE         = 0x00020000,
            SCRIPTCONTF_SCRIPT_SYSTEM       = 0x00040000
        } SCRIPTFONTCONTF;

        typedef struct tagSCRIPFONTINFO
        {
            SCRIPT_IDS  scripts;
            WCHAR       wszFont[MAX_MIMEFACE_NAME];
        } SCRIPTFONTINFO, *PSCRIPTFONTINFO;


        HRESULT GetNumberOfCodePageInfo
        (
            [out, annotation("__out")] UINT          *pcCodePage
        );

        HRESULT GetCodePageInfo
        (
            [in]  UINT                              uiCodePage,
            [in]  LANGID                            LangId,
            [out, annotation("__out")] PMIMECPINFO  pCodePageInfo
        );

        HRESULT GetFamilyCodePage
        (
            [in]  UINT                              uiCodePage,
            [out, annotation("__out")] UINT         *puiFamilyCodePage
        );

        HRESULT EnumCodePages
        (
            [in]  DWORD                                     grfFlags,
            [in]  LANGID                                    LangId,
            [out, annotation("__deref_out")] IEnumCodePage  **ppEnumCodePage
        );

        HRESULT GetCharsetInfo
        (
            [in]  BSTR                                  Charset,
            [out, annotation("__out")] PMIMECSETINFO    pCharsetInfo
        );

        HRESULT IsConvertible
        (
            [in]  DWORD         dwSrcEncoding,
            [in]  DWORD         dwDstEncoding
        );

        HRESULT ConvertString
        (
            [in,out, annotation("__inout_opt")]  DWORD              *pdwMode,
            [in]  DWORD                                             dwSrcEncoding,
            [in]  DWORD                                             dwDstEncoding,
            [in, annotation("__in_bcount_opt(*pcSrcSize)")]  BYTE   *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcSrcSize,
            [out, annotation("__out_bcount_opt(*pcDstSize)")]  BYTE *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcDstSize
        );

        HRESULT ConvertStringToUnicode
        (
            [in,out, annotation("__inout_opt")]  DWORD                  *pdwMode,
            [in]  DWORD                                                 dwEncoding,
            [in, annotation("__in_bcount_opt(*pcSrcSize)")]  CHAR       *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT                   *pcSrcSize,
            [out, annotation("__out_ecount_opt(*pcDstSize)")]  WCHAR    *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT                   *pcDstSize
        );

        HRESULT ConvertStringFromUnicode
        (
            [in,out, annotation("__inout_opt")]  DWORD              *pdwMode,
            [in]  DWORD                                             dwEncoding,
            [in, annotation("__in_ecount_opt(*pcSrcSize)")]  WCHAR  *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcSrcSize,
            [out, annotation("__out_bcount_opt(*pcDstSize)")]  CHAR *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcDstSize
        );

        HRESULT ConvertStringReset();

        HRESULT GetRfc1766FromLcid
        (
            [in]  LCID                              Locale,
            [out, annotation("__deref_out")] BSTR   *pbstrRfc1766
        );

        HRESULT GetLcidFromRfc1766
        (
            [out, annotation("__out")] LCID         *pLocale,
            [in, annotation("__in")]  BSTR          bstrRfc1766
        );

        HRESULT EnumRfc1766
        (
            [in]  LANGID                                    LangId,
            [out, annotation("__deref_out")] IEnumRfc1766   **ppEnumRfc1766
        );

        HRESULT GetRfc1766Info
        (
            [in]  LCID                              Locale,
            [in]  LANGID                            LangId,
            [out, annotation("__out")] PRFC1766INFO pRfc1766Info
        );

        HRESULT CreateConvertCharset
        (
            [in]  UINT                                              uiSrcCodePage,
            [in]  UINT                                              uiDstCodePage,
            [in]  DWORD                                             dwProperty,
            [out, annotation("__deref_out")] IMLangConvertCharset   **ppMLangConvertCharset
        );

        HRESULT ConvertStringInIStream
        (
            [in,out, annotation("__inout_opt")]  DWORD  *pdwMode,
            [in]  DWORD                                 dwFlag,
            [in, annotation("__in_opt")]  WCHAR         *lpFallBack,
            [in]  DWORD                                 dwSrcEncoding,
            [in]  DWORD                                 dwDstEncoding,
            [in, annotation("__in")]  IStream           *pstmIn,
            [in, annotation("__in")]  IStream           *pstmOut
        );

        HRESULT ConvertStringToUnicodeEx
        (
            [in,out, annotation("__inout_opt")]  DWORD              *pdwMode,
            [in]  DWORD                                             dwEncoding,
            [in, annotation("__in_bcount(*pcSrcSize)")]  CHAR       *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcSrcSize,
            [out, annotation("__out_ecount(*pcDstSize)")]  WCHAR    *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT               *pcDstSize,
            [in]  DWORD                                             dwFlag,
            [in, annotation("__in_opt")]  WCHAR                     *lpFallBack
        );

        HRESULT ConvertStringFromUnicodeEx
        (
            [in,out, annotation("__inout_opt")]  DWORD          *pdwMode,
            [in]  DWORD                                         dwEncoding,
            [in, annotation("__in_ecount(*pcSrcSize)")]  WCHAR  *pSrcStr,
            [in,out, annotation("__inout_opt")]  UINT           *pcSrcSize,
            [out, annotation("__out_bcount(*pcDstSize)")]  CHAR *pDstStr,
            [in,out, annotation("__inout_opt")]  UINT           *pcDstSize,
            [in]  DWORD                                         dwFlag,
            [in, annotation("__in_opt")]  WCHAR                 *lpFallBack
        );

        HRESULT DetectCodepageInIStream
        (
            [in]  DWORD                                     dwFlag,
            [in]  DWORD                                     dwPrefWinCodePage,
            [in, annotation("__in")]  IStream               *pstmIn,
            [out, annotation("__out")] DetectEncodingInfo   *lpEncoding,
            [in,out, annotation("__inout")] INT             *pnScores
        );

        HRESULT DetectInputCodepage
        (
            [in]  DWORD                                         dwFlag,
            [in]  DWORD                                         dwPrefWinCodePage,
            [in, annotation("__in_bcount(*pcSrcSize)")]  CHAR   *pSrcStr,
            [in,out, annotation("__inout")] INT                 *pcSrcSize,
            [out, annotation("__out")] DetectEncodingInfo       *lpEncoding,
            [in,out, annotation("__inout")] INT                 *pnScores
        );

        HRESULT ValidateCodePage
        (
            [in] UINT      uiCodePage,
            [in] HWND      hwnd
        );

        HRESULT GetCodePageDescription
        (
            [in] UINT                                                                   uiCodePage,
            [in] LCID                                                                   lcid, 
            [out,size_is(cchWideChar), annotation("__out_ecount(cchWideChar)")]LPWSTR   lpWideCharStr,
            [in]  int                                                                   cchWideChar
        );

        HRESULT IsCodePageInstallable
        (
            [in] UINT      uiCodePage
        );

        HRESULT SetMimeDBSource
        (
            [in] MIMECONTF dwSource
        );

        HRESULT GetNumberOfScripts
        (
            [out, annotation("__out")] UINT          *pnScripts
        );


        HRESULT EnumScripts
        (
            [in]  DWORD                                     dwFlags,
            [in]  LANGID                                    LangId,
            [out, annotation("__deref_out")] IEnumScript   **ppEnumScript
        );

        HRESULT ValidateCodePageEx
        (
            [in] UINT      uiCodePage,
            [in] HWND      hwnd,
            [in] DWORD     dwfIODControl
        );

    };

    [
        uuid(359F3443-BD4A-11D0-B188-00AA0038C969),
        helpstring("IMLangCodePages Interface"),
        pointer_default(unique),
        local
    ]
    interface IMLangCodePages : IUnknown
    {
        typedef [unique] IMLangCodePages* PMLANGCODEPAGES;

        [helpstring("method GetCharCodePages")] HRESULT GetCharCodePages([in] WCHAR chSrc, [out, annotation("__out")] DWORD* pdwCodePages);
        [helpstring("method GetStrCodePages")] HRESULT GetStrCodePages([in, size_is(cchSrc), annotation("__in_ecount(cchSrc)")] const WCHAR* pszSrc, [in] long cchSrc, [in] DWORD dwPriorityCodePages, [out, annotation("__out_opt")] DWORD* pdwCodePages, [out, annotation("__out_opt")] long* pcchCodePages);
        [helpstring("method CodePageToCodePages")] HRESULT CodePageToCodePages([in] UINT uCodePage, [out, annotation("__out")] DWORD* pdwCodePages);
        [helpstring("method CodePagesToCodePage")] HRESULT CodePagesToCodePage([in] DWORD dwCodePages, [in] UINT uDefaultCodePage, [out, annotation("__out")] UINT* puCodePage);

    };

    [
        uuid(359F3441-BD4A-11D0-B188-00AA0038C969),
        helpstring("IMLangFontLink Interface"),
        pointer_default(unique),
        local
    ]
    interface IMLangFontLink : IMLangCodePages
    {
        typedef [unique] IMLangFontLink* PMLANGFONTLINK;

        [helpstring("method GetFontCodePages")] HRESULT GetFontCodePages([in] HDC hDC, [in] HFONT hFont, [out, annotation("__out_opt")] DWORD* pdwCodePages);
        [helpstring("method MapFont")] HRESULT MapFont([in] HDC hDC, [in] DWORD dwCodePages, [in] HFONT hSrcFont, [out, annotation("__out_opt")] HFONT* phDestFont);
        [helpstring("method ReleaseFont")] HRESULT ReleaseFont([in] HFONT hFont);
        [helpstring("method ResetFontMapping")] HRESULT ResetFontMapping();

    };

    [
        uuid(DCCFC162-2B38-11d2-B7EC-00C04F8F5D9A),
        helpstring("IMLangFontLink2 Interface"),
        pointer_default(unique),
        local
    ]
    interface IMLangFontLink2 : IMLangCodePages
    {
        typedef struct tagUNICODERANGE
        {
            WCHAR wcFrom;
            WCHAR wcTo;
        } UNICODERANGE;

        typedef [unique] IMLangFontLink2* PMLANGFONTLINK2;

        [helpstring("method GetFontCodePages")] HRESULT GetFontCodePages([in] HDC hDC, [in] HFONT hFont, [out, annotation("__out_opt")] DWORD* pdwCodePages);
        [helpstring("method ReleaseFont")] HRESULT ReleaseFont([in] HFONT hFont);
        [helpstring("method ResetFontMapping")] HRESULT ResetFontMapping();
        [helpstring("method MapFont")] HRESULT MapFont([in] HDC hDC, [in] DWORD dwCodePages,  [in] WCHAR chSrc, [out, annotation("__out_opt")] HFONT* pFont );
        [helpstring("method GetFontUnicodeRanges")] HRESULT GetFontUnicodeRanges([in] HDC hDC, [in,out, annotation("__in")] UINT *puiRanges, [out, annotation("__out_opt")] UNICODERANGE* pUranges);
        [helpstring("method GetScriptFontInfo")]HRESULT GetScriptFontInfo([in] SCRIPT_ID sid, [in] DWORD dwFlags, [in, out, annotation("__inout")] UINT *puiFonts, [out, annotation("__out_opt")] SCRIPTFONTINFO* pScriptFont);
        [helpstring("method CodePageToScriptID")] HRESULT CodePageToScriptID([in] UINT uiCodePage, [out, annotation("__out")] SCRIPT_ID *pSid);
    };

    [
        object,
        uuid(4e5868ab-b157-4623-9acc-6a1d9caebe04),
        pointer_default(unique),
        local
    ]
    interface IMultiLanguage3 : IMultiLanguage2
    {
       typedef [unique] IMultiLanguage3 *LPMULTILANGUAGE3;
       HRESULT DetectOutboundCodePage(
            [in] DWORD           dwFlags,                
            [in, size_is(cchWideChar), annotation("__in_ecount(cchWideChar)")] LPCWSTR lpWideCharStr,          
            [in] UINT            cchWideChar,            
            [in, size_is(nPreferredCodePages), annotation("__in_ecount_opt(nPreferredCodePages)")] const UINT* puiPreferredCodePages,  
            [in] UINT            nPreferredCodePages,    
            [out, size_is(*pnDetectedCodePages), annotation("__out_ecount_part(*pnDetectedCodePages, *pnDetectedCodePages)")] UINT* puiDetectedCodePages,   
            [in, out, annotation("__inout")] UINT*      pnDetectedCodePages,    
            [in, unique, string, annotation("__in_opt")] LPCWSTR lpSpecialChar
            );

       HRESULT DetectOutboundCodePageInIStream(
            [in] DWORD          dwFlags,                
            [in, annotation("__in")] IStream*       pStrIn,                 
            [in, size_is(nPreferredCodePages), annotation("__in_ecount_opt(nPreferredCodePages)")] const UINT* puiPreferredCodePages,
            [in] UINT           nPreferredCodePages,    
            [out, size_is(*pnDetectedCodePages), annotation("__out_ecount_part(*pnDetectedCodePages, *pnDetectedCodePages)")] UINT* puiDetectedCodePages,   
            [in, out, annotation("__inout")] UINT*     pnDetectedCodePages,                                                        
            [in, unique, string, annotation("__in_opt")] LPCWSTR lpSpecialChar
            );
    };

    [
        uuid(275c23e2-3747-11d0-9fea-00aa003f8646),
    ]
    coclass CMultiLanguage
    {
        [default] interface IMultiLanguage;
        interface IMLangCodePages;
        interface IMLangFontLink;
        interface IMLangLineBreakConsole;
        interface IMultiLanguage2;
        interface IMLangFontLink2;
        interface IMultiLanguage3;
    };
}


cpp_quote("#ifndef _MLANG_H_API_DEF_                                                     ")
cpp_quote("#define _MLANG_H_API_DEF_                                                     ")
cpp_quote("                                                                              ")
cpp_quote("// APIs prototypes                                                            ")
cpp_quote("STDAPI LcidToRfc1766A(__in LCID Locale, __out_bcount(iMaxLength) LPSTR pszRfc1766, __in int iMaxLength);         ")
cpp_quote("STDAPI LcidToRfc1766W(__in LCID Locale, __out_ecount(nChar) LPWSTR pwszRfc1766, __in int nChar);             ")
cpp_quote("#ifdef UNICODE                                                                ")
cpp_quote("#define LcidToRfc1766        LcidToRfc1766W                                   ")
cpp_quote("#else                                                                         ")
cpp_quote("#define LcidToRfc1766        LcidToRfc1766A                                   ")
cpp_quote("#endif                                                                        ")
cpp_quote("STDAPI Rfc1766ToLcidA(__out LCID *pLocale, __in LPCSTR pszRfc1766);           ")
cpp_quote("STDAPI Rfc1766ToLcidW(__out LCID *pLocale, __in LPCWSTR pszRfc1766);          ")
cpp_quote("#ifdef UNICODE                                                                ")
cpp_quote("#define Rfc1766ToLcid        Rfc1766ToLcidW                                   ")
cpp_quote("#else                                                                         ")
cpp_quote("#define Rfc1766ToLcid        Rfc1766ToLcidA                                   ")
cpp_quote("#endif                                                                        ")
cpp_quote("                                                                              ")
cpp_quote("STDAPI IsConvertINetStringAvailable(DWORD dwSrcEncoding, DWORD dwDstEncoding);")
cpp_quote("STDAPI ConvertINetString(__inout_opt LPDWORD lpdwMode, __in DWORD dwSrcEncoding, __in DWORD dwDstEncoding, __in_bcount_opt(*lpnSrcSize) LPCSTR lpSrcStr, __inout_opt LPINT lpnSrcSize, __out_bcount_opt(*lpnDstSize) LPSTR lpDstStr, __inout_opt LPINT lpnDstSize); ")
cpp_quote("STDAPI ConvertINetMultiByteToUnicode(__inout_opt LPDWORD lpdwMode, __in DWORD dwEncoding, __in_opt LPCSTR lpSrcStr, __inout_opt LPINT lpnMultiCharCount, __out_ecount_opt(*lpnWideCharCount) LPWSTR lpDstStr, __inout_opt LPINT lpnWideCharCount); ")
cpp_quote("STDAPI ConvertINetUnicodeToMultiByte(__inout_opt LPDWORD lpdwMode, __in DWORD dwEncoding, __in_opt LPCWSTR lpSrcStr, __inout_opt LPINT lpnWideCharCount, __out_bcount_opt(*lpnMultiCharCount) LPSTR lpDstStr, __inout_opt LPINT lpnMultiCharCount); ")
cpp_quote("                                                                              ")
cpp_quote("#endif // _MLANG_H_API_DEF_                                                   ")

