如何获得字符集列表?100分(100分)

  • 主题发起人 主题发起人 轻音乐
  • 开始时间 开始时间

轻音乐

Unregistered / Unconfirmed
GUEST, unregistred user!
如何获得字符集列表?100分
 
字符集吗?很多啊,包括中文吗?
看看这个是不是你要的: 在帮助里的。
Unit

Sysutils

type TFontCharset = 0..255;

Description

Each Windows typeface supports one or more character sets. The particular character sets depend on the font. Check with the font vendor to determine which typeface抯 are supported.

The following table lists the predefined constants provided for standard character sets:

Constant Value Description

ANSI_CHARSET 0 ANSI characters.
DEFAULT_CHARSET 1 Font is chosen based solely on Name and Size. If the described font is not available on the system, Windows will substitute another font.
SYMBOL_CHARSET 2 Standard symbol set.
MAC_CHARSET 77 Macintosh characters. Not available on NT 3.51.
SHIFTJIS_CHARSET 128 Japanese shift-jis characters.
HANGEUL_CHARSET 129 Korean characters (Wansung).
JOHAB_CHARSET 130 Korean characters (Johab). Not available on NT 3.51

GB2312_CHARSET 134 Simplified Chinese characters (mainland china).
CHINESEBIG5_CHARSET 136 Traditional Chinese characters (taiwanese).
GREEK_CHARSET 161 Greek characters. Not available on NT 3.51.
TURKISH_CHARSET 162 Turkish characters. Not available on NT 3.51
VIETNAMESE_CHARSET 163 Vietnamese characters. Not available on NT 3.51.
HEBREW_CHARSET 177 Hebrew characters. Not available on NT 3.51
ARABIC_CHARSET 178 Arabic characters. Not available on NT 3.51

BALTIC_CHARSET 186 Baltic characters. Not available on NT 3.51.
RUSSIAN_CHARSET 204 Cyrillic characters. Not available on NT 3.51.
THAI_CHARSET 222 Thai characters. Not available on NT 3.51
EASTEUROPE_CHARSET 238 Includes diacritical marks for eastern european countries. Not available on NT 3.51.
OEM_CHARSET 255 Depends on the codepage of the operating system.
 
下面的是系统的字符集,不知是否是你想要的.
注释掉的那行表示是否是安装的字符集,你根据自己的需要选择吧.
radiogroup1中的三个item文字分别为:

1.Use the system defau - ANSI code page
2.Windows NT/2000/XP: Use the system defaul - Macintosh code page
3 Use the system default - OEM code page
====================================================================
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Menus, ExtCtrls;

type
PCPInfoEX = ^TCPInfoEx;
TCPInfoEx = record
MaxCharSize: UINT;
DefaultChar: array[0..MAX_DEFAULTCHAR - 1] of byte;
LeadByte: array[0..MAX_LEADBYTES - 1] of byte;
UnicodeDefaultChar: WChar;
CodePage: UINT;
CodePageName: array[0..MAX_PATH - 1] of Char;
end;

TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
BitBtn1: TBitBtn;
Button2: TButton;
RadioGroup1: TRadioGroup;
procedure Button1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
OEMList: TStringList;
ANSIList: TStringList;
MacintoshList: TStringList;
public
{ Public declarations }
List: TStringList;
end;
function GetCPInfoExA(CodePage: UINT; dwFalgs: DWORD; lpCPInfoEx: PCPInfoEx): bool; stdcall;
external 'Kernel32.dll';

function EnumCodePagesProc(lpCodePageString: pchar): boolean; stdcall;
var
Form1: TForm1;

implementation

{$R *.DFM}

function EnumCodePagesProc(lpCodePageString: pchar): boolean;
begin
form1.List.Add(lpCodePageString);
result := True;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
cp: TCPInfoEx;
begin
AnsiList.Clear;
OEMList.Clear;
MacintoshList.Clear;
for i := 0 to List.Count-1 do
begin
if GetCPInfoExA(strtoint(List.Strings), CP_ACP, @cp) then
AnsiList.Add(cp.CodePageName);
if GetCPInfoExA(strtoint(List.Strings), CP_MACCP, @cp) then
MacintoshList.Add(cp.CodePageName);
if GetCPInfoExA(strtoint(List.Strings), CP_OEMCP, @cp) then
OEMList.Add(cp.CodePageName);
end;

end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
EnumSystemCodePages(@enumcodepagesproc, CP_SUPPORTED);

// EnumSystemCodePages(@enumcodepagesproc, CP_INSTALLED);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
List := TStringList.Create;
OEMList := TStringList.Create;
AnsiList := TStringList.Create;
MacintoshList := TStringList.Create;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
case radiogroup1.ItemIndex of
0: listbox1.Items := AnsiList;
1: listbox1.Items := MacintoshList;
2: listbox1.Items := OEMList;
end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
AnsiList.Free;
OEMList.Free;
MacintoshList.Free;
end;

end.
 
to bluerain: 你好,你的方法可行,只是我还想要更多的字符集,
象安装oracle时选择字符集时那样的列表,不知能否实现,请你帮忙,
若能实现马上放分。
 
sorry,我没用过Oracle,所以不知道是怎么样的.
一般选择的是系统安装过的字符集,你安装了多少字符集,就列出多少.
这两天老婆生孩子,所以没有时间玩电脑了.见谅.
 
这个符合你的要求吗?
Function GetLanguage:string;
var
i:integer;
sLists:TStrings;
begin
sLists:=TStringList.Create;
try
for i:=0 to Languages.Count-1 do
sLists.Add(Languages.Name+'['+IntToHex(Languages.LocaleID,4)+']');
except
end;
Result:=sLists.Text;
FreeAndNil(sLists);
end;
 
多人接受答案了。
 

Similar threads

后退
顶部