IMLangCodePages::CodePagesToCodePage method

Gets the identifier value for a code page in the given set of code pages.

Syntax

HRESULT CodePagesToCodePage(
  [in]  DWORD dwCodePages,
  [in]  UINT  uDefaultCodePage,
  [out] UINT  *puCodePage
);

Parameters

  • dwCodePages [in]
    The source set of code pages.

  • uDefaultCodePage [in]
    A default code page to look for in the set.

  • puCodePage [out]
    A pointer to an unsigned integer where the code page identifier value is returned.

Return value

Returns S_OK if successful, or E_FAIL if an error occurs.

Remarks

See IMLangCodePages for more information about sets of code pages.

If uDefaultCodePage is in the set of code pages specified by dwCodePages, the method returns uDefaultCodePage. If no default code page is given, the method returns the code page identifier value corresponding to the least significant bit that has been set to 1. For example, if dwCodePages is 0x1e0000, and uDefaultCodePage is not in the set, the method returns the code page that corresponds to the bit 0x020000.

Examples

This example shows how to convert a set of code pages into an array of corresponding MIMECPINFO structures.

// dwCodePages - DWORD representing a set of code pages.
// pcpInfo - caller-allocated array of MIMECPINFO structures.
// pMultiLanguage - pointer to an IMultiLanguage interface.
// pMLangCodePages - pointer to an IMLangCodePages interface.

for(int i = 0; dwCodePages; i++)
{
    UINT uCodePage;
    DWORD dwTemporaryCodePages;

    pMLangCodePages->CodePagesToCodePage(dwCodePages, CP_ACP,
        &uCodePage);

    pMultiLanguage->GetCodePageInfo(uCodePage, pcpInfo + i);

    pMLangCodePages->CodePageToCodePages(uCodePage,
        &dwTemporaryCodePages);

    dwCodePages &= ~dwTemporaryCodePages;
}

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Header

Mlang.h

IDL

Mlang.idl

DLL

Mlang.dll

See also

IMLangCodePages

IMLangCodePages::CodePageToCodePages