ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBCodePage.pas
Revision: 39
Committed: Tue May 17 08:14:52 2016 UTC (8 years, 6 months ago) by tony
Content type: text/x-pascal
File size: 3670 byte(s)
Log Message:
Committing updates for Release R1-4-1

File Contents

# Content
1 unit IBCodePage;
2
3 {$mode objfpc}{$H+}
4 {$IF FPC_FULLVERSION >= 20700 }
5 {$codepage UTF8}
6 {$DEFINE HAS_ANSISTRING_CODEPAGE}
7 {$ENDIF}
8
9 interface
10
11 uses
12 Classes, SysUtils;
13
14 {$IFDEF HAS_ANSISTRING_CODEPAGE}
15 function IBGetCodePage(IBCP_Name: string): TSystemCodePage;
16 function IBGetCharacterSetName(CodePage: TSystemCodePage): RawByteString;
17 {$ENDIF}
18
19 implementation
20
21 {$IFDEF HAS_ANSISTRING_CODEPAGE}
22
23 type
24 TIBCodePage = record
25 IBCharacterSetName: string;
26 cp: TSystemCodePage;
27 end;
28
29 { Code Page numbers should align with CodePageNames array in Sysutils}
30 const
31 IBCodePages: array [0..51] of TIBCodePage = (
32 (IBCharacterSetName: 'UTF8'; cp: CP_UTF8),
33 (IBCharacterSetName: 'NONE'; cp: CP_NONE),
34 (IBCharacterSetName: 'OCTETS'; cp: CP_NONE),
35 (IBCharacterSetName: 'ASCII'; cp: CP_ASCII),
36 (IBCharacterSetName: 'SJIS_0208'; cp: 932),
37 (IBCharacterSetName: 'WIN1250'; cp: 1250),
38 (IBCharacterSetName: 'WIN1251'; cp: 1251),
39 (IBCharacterSetName: 'WIN1252'; cp: 1252),
40 (IBCharacterSetName: 'WIN1253'; cp: 1253),
41 (IBCharacterSetName: 'WIN1254'; cp: 1254),
42 (IBCharacterSetName: 'WIN1255'; cp: 1255),
43 (IBCharacterSetName: 'WIN1256'; cp: 1256),
44 (IBCharacterSetName: 'WIN1257'; cp: 1257),
45 (IBCharacterSetName: 'WIN1258'; cp: 1258),
46 (IBCharacterSetName: 'ISO8859_1'; cp: 28591),
47 (IBCharacterSetName: 'ISO8859_2'; cp: 28592),
48 (IBCharacterSetName: 'ISO8859_3'; cp: 28593),
49 (IBCharacterSetName: 'ISO8859_4'; cp: 28594),
50 (IBCharacterSetName: 'ISO8859_5'; cp: 28595),
51 (IBCharacterSetName: 'ISO8859_6'; cp: 28596),
52 (IBCharacterSetName: 'ISO8859_7'; cp: 28597),
53 (IBCharacterSetName: 'ISO8859_8'; cp: 28598),
54 (IBCharacterSetName: 'ISO8859_9'; cp: 28599),
55 (IBCharacterSetName: 'ISO8859_13'; cp: 28603),
56 (IBCharacterSetName: 'EUCJ_0208'; cp: 20932),
57 (IBCharacterSetName: 'DOS437'; cp: 437),
58 (IBCharacterSetName: 'DOS850'; cp: 850),
59 (IBCharacterSetName: 'DOS865'; cp: 865),
60 (IBCharacterSetName: 'DOS852'; cp: 852),
61 (IBCharacterSetName: 'DOS857'; cp: 857),
62 (IBCharacterSetName: 'DOS860'; cp: 860),
63 (IBCharacterSetName: 'DOS861'; cp: 861),
64 (IBCharacterSetName: 'DOS863'; cp: 863),
65 (IBCharacterSetName: 'CYRL'; cp: 28595),
66 (IBCharacterSetName: 'DOS737'; cp: 737),
67 (IBCharacterSetName: 'DOS775'; cp: 775),
68 (IBCharacterSetName: 'DOS858'; cp: 858),
69 (IBCharacterSetName: 'DOS862'; cp: 862),
70 (IBCharacterSetName: 'DOS864'; cp: 864),
71 (IBCharacterSetName: 'DOS866'; cp: 866),
72 (IBCharacterSetName: 'DOS869'; cp: 869),
73 (IBCharacterSetName: 'NEXT'; cp: CP_NONE),
74 (IBCharacterSetName: 'KSC_5601'; cp: 949),
75 (IBCharacterSetName: 'BIG_5'; cp: 950),
76 (IBCharacterSetName: 'GB_2312'; cp: 52936),
77 (IBCharacterSetName: 'KOI8R'; cp: 20866),
78 (IBCharacterSetName: 'KOI8U'; cp: 21866),
79 (IBCharacterSetName: 'TIS620'; cp: 20838),
80 (IBCharacterSetName: 'GBK'; cp: 936),
81 (IBCharacterSetName: 'CP943C'; cp: 50220),
82 (IBCharacterSetName: 'UNICODE_FSS'; cp: CP_UTF8),
83 (IBCharacterSetName: 'GB18030' ; cp: 54936)
84 );
85
86 function IBGetCodePage(IBCP_Name: string): TSystemCodePage;
87 var I: integer;
88 begin
89 Result := CP_NONE;
90 for I := Low(IBCodePages) to High(IBCodePages) do
91 if IBCodePages[I].IBCharacterSetName = IBCP_Name then
92 begin
93 Result := IBCodePages[I].cp;
94 Exit;
95 end;
96 end;
97
98 function IBGetCharacterSetName(CodePage: TSystemCodePage): RawByteString;
99 var I: integer;
100 begin
101 Result := 'UTF8';
102 for I := Low(IBCodePages) to High(IBCodePages) do
103 if IBCodePages[I].cp = CodePage then
104 begin
105 Result := IBCodePages[I].IBCharacterSetName;
106 Exit;
107 end;
108 end;
109
110 {$ENDIF}
111
112 end.
113