OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TCodePages Class Reference

Encapsulates Windows code page functionality. More...

#include <owl/codepages.h>

Public Types

using TCodePageId = uint
 Define the code page, code page object, and container types.
using TCodePage = struct { TCodePageId CodePageId; bool Installed; tstring Name; }
using TCodePageList = std::vector<TCodePage>

Static Public Member Functions

Code Page List Operations
static auto GetCodePageList () -> const TCodePageList &
 Retrieves the code page list.
static auto GetIndex (TCodePageId idCodePage) -> int
 Searches the code page list for a code page identifier.
Code Page WINAPI Wrapper Operations
static auto GetOemCodePageId () -> TCodePageId
 Retrieves the current OEM code page identifier.
static auto SetOemCodePageId (TCodePageId idCodePage) -> bool
 Sets the current OEM code page identifier.
static auto GetAnsiCodePageId () -> TCodePageId
 Retrieves the current ANSI code page identifier.
static auto SetAnsiCodePageId (TCodePageId idCodePage) -> bool
 Sets the current ANSI code page identifier.
static auto GetCodePageInfoEx (TCodePageId idCodePage) -> CPINFOEX
 Retieves a CPINFOEX structure.
static auto GetCodePageInfo (TCodePageId idCodePage) -> CPINFO
 Retieves a CPINFO structure.
static auto GetMultiByteCodePage () -> TCodePageId
 Retieves the multi-byte code page identifier.
static auto SetMultiByteCodePage (TCodePageId idCodePage) -> bool
 Sets the multi-byte code page identifier.

Detailed Description

Encapsulates Windows code page functionality.

TCodePages is a static class and instantiation is not allowed. The code page list does not get loaded until accessed using GetCodePageList or GetIndex. Loading is performed only once and is persistent until the application terminates. The following sample code illustrates loading the code page list in a TComboBox control, retrieving the current code page identifier, initializing the selection of the control to the currently selected code page identifier, and changing the current code page to the user selection.

TComboBox* cbox = new TComboBox(/*...*/);
// ...
for (auto &cp : TCodePages::GetCodePageList())
cbox->AddString(cp.Name);
if (iCur != -1) cbox->SetSelIndex(iCur);
// ...
auto iSel = cbox->GetSelIndex();
if (iSel != -1) TCodePages::SetAnsiCodePageId(TCodePages::GetCodePageList().at(iSel).CodePageId);
static auto GetIndex(TCodePageId idCodePage) -> int
Searches the code page list for a code page identifier.
Definition codepages.cpp:92
static auto SetAnsiCodePageId(TCodePageId idCodePage) -> bool
Sets the current ANSI code page identifier.
Definition codepages.h:138
static auto GetAnsiCodePageId() -> TCodePageId
Retrieves the current ANSI code page identifier.
Definition codepages.h:122
static auto GetCodePageList() -> const TCodePageList &
Retrieves the code page list.
You can use TComboBox to create a combo box or a combo box control in a parent TWindow,...
Definition combobox.h:47
TComboBox(TWindow *parent, int id, int x, int y, int w, int h, uint32 style, uint textLimit, TModule *module=0)
Constructs a combo box object with the specified parent window (parent), control ID (Id),...
Definition combobox.cpp:178
virtual int AddString(LPCTSTR str)
Adds a string to an associated list part of a combo box.
Definition combobox.h:356
virtual int GetSelIndex() const
Returns the index of the list selection or a negative value if none exists.
Definition combobox.h:544
virtual int SetSelIndex(int index)
Selects a string of characters in a combo box.
Definition combobox.h:555

Definition at line 61 of file codepages.h.

Member Typedef Documentation

◆ TCodePage

using owl::TCodePages::TCodePage = struct { TCodePageId CodePageId; bool Installed; tstring Name; }

Definition at line 69 of file codepages.h.

◆ TCodePageId

Define the code page, code page object, and container types.

Definition at line 68 of file codepages.h.

◆ TCodePageList

Definition at line 70 of file codepages.h.

Member Function Documentation

◆ GetAnsiCodePageId()

auto owl::TCodePages::GetAnsiCodePageId ( ) -> TCodePageId
inlinestatic

Retrieves the current ANSI code page identifier.

Wrapper function for the Windows API GetACP.

Returns
current ANSI code page identifier.
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/dd318070.aspx

Definition at line 122 of file codepages.h.

◆ GetCodePageInfo()

auto owl::TCodePages::GetCodePageInfo ( TCodePageId idCodePage) -> CPINFO
inlinestatic

Retieves a CPINFO structure.

Wrapper function for the Windows API GetCPInfo.

Parameters
[in]idCodePageis the code page identifier to use.
Returns
the CPINFO structure.
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/dd318078.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd317780.aspx

Definition at line 172 of file codepages.h.

◆ GetCodePageInfoEx()

auto owl::TCodePages::GetCodePageInfoEx ( TCodePageId idCodePage) -> CPINFOEX
inlinestatic

Retieves a CPINFOEX structure.

Wrapper function for the Windows API GetCPInfoEx.

Parameters
[in]idCodePageis the code page identifier to use.
Returns
the CPINFOEX structure.
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/dd318081.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/dd317781.aspx

Definition at line 153 of file codepages.h.

◆ GetCodePageList()

auto owl::TCodePages::GetCodePageList ( ) -> const TCodePageList &
static

Retrieves the code page list.

Returns
the code page list.

Definition at line 104 of file codepages.cpp.

◆ GetIndex()

auto owl::TCodePages::GetIndex ( TCodePageId idCodePage) -> int
static

Searches the code page list for a code page identifier.

Parameters
[in]idCodePageis the code page identifier to find.
Returns
the index of the code page list for the identifier or -1 if not found.

Definition at line 92 of file codepages.cpp.

◆ GetMultiByteCodePage()

auto owl::TCodePages::GetMultiByteCodePage ( ) -> TCodePageId
inlinestatic

Retieves the multi-byte code page identifier.

Wrapper function for the Windows API _getmbcp.

Returns
the multi-byte code page identifier.
See also
http://msdn.microsoft.com/en-us/library/4115fwez.aspx

Definition at line 188 of file codepages.h.

◆ GetOemCodePageId()

auto owl::TCodePages::GetOemCodePageId ( ) -> TCodePageId
inlinestatic

Retrieves the current OEM code page identifier.

Wrapper function for the Windows API GetOEMCP.

Returns
current OEM code page identifier.
See also
http://msdn.microsoft.com/en-us/library/windows/desktop/dd318114.aspx

Definition at line 94 of file codepages.h.

◆ SetAnsiCodePageId()

auto owl::TCodePages::SetAnsiCodePageId ( TCodePageId idCodePage) -> bool
inlinestatic

Sets the current ANSI code page identifier.

Wrapper function for the Windows API SetACP.

Parameters
[in]idCodePageis the code page identifier to set.
Note
Avaiable for WINCE only.
Returns
true if successful.
See also
http://msdn.microsoft.com/en-us/library/gg155975.aspx

Definition at line 138 of file codepages.h.

References OWL_SET_ANSICP_.

◆ SetMultiByteCodePage()

auto owl::TCodePages::SetMultiByteCodePage ( TCodePageId idCodePage) -> bool
inlinestatic

Sets the multi-byte code page identifier.

Wrapper function for the Windows API _setmbcp.

Parameters
[in]idCodePageis the code page identifier to set.
Returns
true if successful.
See also
http://msdn.microsoft.com/en-us/library/883tf19a.aspx

Definition at line 202 of file codepages.h.

◆ SetOemCodePageId()

auto owl::TCodePages::SetOemCodePageId ( TCodePageId idCodePage) -> bool
inlinestatic

Sets the current OEM code page identifier.

Wrapper function for the Windows API SetOEMCP.

Parameters
[in]idCodePageis the code page identifier to set.
Note
Avaiable for WINCE only.
Returns
true if successful.
See also
http://msdn.microsoft.com/en-us/library/gg155426.aspx

Definition at line 110 of file codepages.h.

References OWL_SET_OEMCP_.


The documentation for this class was generated from the following files: