xref: /haiku/src/kits/textencoding/CharacterSet.cpp (revision 99ff9094c790d2e411592692297719d1fb05aa2f)
1 #include <CharacterSet.h>
2 
3 namespace BPrivate {
4 
BCharacterSet()5 BCharacterSet::BCharacterSet()
6 {
7 	id = 0;
8 	MIBenum = 106;
9 	print_name = "Unicode";
10 	iana_name = "UTF-8";
11 	mime_name = "UTF-8";
12 	aliases_count = 0;
13 	aliases = NULL;
14 }
15 
BCharacterSet(uint32 _id,uint32 _MIBenum,const char * _print_name,const char * _iana_name,const char * _mime_name,const char ** _aliases)16 BCharacterSet::BCharacterSet(uint32 _id, uint32 _MIBenum, const char * _print_name,
17                              const char * _iana_name, const char * _mime_name,
18                              const char ** _aliases)
19 {
20 	id = _id;
21 	MIBenum = _MIBenum;
22 	print_name = _print_name;
23 	iana_name = _iana_name;
24 	mime_name = _mime_name;
25 	aliases_count = 0;
26 	if (_aliases != 0) {
27 		while (_aliases[aliases_count] != 0) {
28 			aliases_count++;
29 		}
30 	}
31 	aliases = _aliases;
32 }
33 
34 uint32
GetFontID() const35 BCharacterSet::GetFontID() const
36 {
37 	return id;
38 }
39 
40 uint32
GetConversionID() const41 BCharacterSet::GetConversionID() const
42 {
43 	return id-1;
44 }
45 
46 uint32
GetMIBenum() const47 BCharacterSet::GetMIBenum() const
48 {
49 	return MIBenum;
50 }
51 
52 const char *
GetName() const53 BCharacterSet::GetName() const
54 {
55 	return iana_name;
56 }
57 
58 const char *
GetPrintName() const59 BCharacterSet::GetPrintName() const
60 {
61 	return print_name;
62 }
63 
64 const char *
GetMIMEName() const65 BCharacterSet::GetMIMEName() const
66 {
67 	return mime_name;
68 }
69 
70 int32
CountAliases() const71 BCharacterSet::CountAliases() const
72 {
73 	return aliases_count;
74 }
75 
76 const char *
AliasAt(uint32 index) const77 BCharacterSet::AliasAt(uint32 index) const
78 {
79 	if (index >= aliases_count) {
80 		return 0;
81 	}
82 	return aliases[index];
83 }
84 
85 }
86