xref: /haiku/src/kits/textencoding/CharacterSet.cpp (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 #include <CharacterSet.h>
2 
3 namespace BPrivate {
4 
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 
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
35 BCharacterSet::GetFontID() const
36 {
37 	return id;
38 }
39 
40 uint32
41 BCharacterSet::GetConversionID() const
42 {
43 	return id-1;
44 }
45 
46 uint32
47 BCharacterSet::GetMIBenum() const
48 {
49 	return MIBenum;
50 }
51 
52 const char *
53 BCharacterSet::GetName() const
54 {
55 	return iana_name;
56 }
57 
58 const char *
59 BCharacterSet::GetPrintName() const
60 {
61 	return print_name;
62 }
63 
64 const char *
65 BCharacterSet::GetMIMEName() const
66 {
67 	return mime_name;
68 }
69 
70 int32
71 BCharacterSet::CountAliases() const
72 {
73 	return aliases_count;
74 }
75 
76 const char *
77 BCharacterSet::AliasAt(uint32 index) const
78 {
79 	if (index >= aliases_count) {
80 		return 0;
81 	}
82 	return aliases[index];
83 }
84 
85 }
86