2 // DateTimeFormatEntry.cs
5 // Jackson Harper (jackson@ximian.com)
6 // Marek Safar <marek.safar@gmail.com>
8 // (C) 2004, Novell, Inc (http://www.novell.com)
9 // Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Globalization
;
34 namespace Mono
.Tools
.LocaleBuilder
36 public class NumberFormatEntry
: Entry
38 public string CurrencyDecimalDigits
;
39 public string CurrencyDecimalSeparator
= ",";
40 public string CurrencyGroupSeparator
= ",";
41 public string[] CurrencyGroupSizes
= new string[Constants
.GROUP_SIZE
];
42 public string CurrencyNegativePattern
;
43 public string CurrencyPositivePattern
;
44 public string CurrencySymbol
;
45 public string NaNSymbol
;
46 public string NegativeSign
= "-";
47 public int NumberDecimalDigits
;
48 public string NumberDecimalSeparator
= ",";
49 public string NumberGroupSeparator
= ",";
50 public string[] NumberGroupSizes
= new string[Constants
.GROUP_SIZE
];
51 public string NumberNegativePattern
;
52 public int PercentDecimalDigits
;
53 public string PercentDecimalSeparator
= ",";
54 public string PercentGroupSeparator
= ",";
55 public string[] PercentGroupSizes
= new string[Constants
.GROUP_SIZE
];
56 public string PercentNegativePattern
;
57 public string PercentPositivePattern
;
58 public string PercentSymbol
= "%";
59 public string PerMilleSymbol
= "‰";
60 public string InfinitySymbol
= "Infinity";
61 public string PositiveSign
= "+";
62 public DigitShapes DigitSubstitution
= DigitShapes
.None
;
63 public string[] NativeDigits
= new string[10] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
;
67 public string NegativeInfinitySymbol
71 if (InfinitySymbol
.StartsWith (PositiveSign
))
72 return NegativeSign
+ InfinitySymbol
.Substring (1, InfinitySymbol
.Length
- 1);
74 return NegativeSign
+ InfinitySymbol
;
78 public string PositiveInfinitySymbol
82 return InfinitySymbol
;
86 public void AppendTableRow (StringBuilder builder
)
88 builder
.Append ("\t{");
90 builder
.Append (EncodeStringIdx (CurrencyDecimalSeparator
) + ", ");
91 builder
.Append (EncodeStringIdx (CurrencyGroupSeparator
) + ", ");
92 builder
.Append (EncodeStringIdx (PercentDecimalSeparator
) + ", ");
93 builder
.Append (EncodeStringIdx (PercentGroupSeparator
) + ", ");
94 builder
.Append (EncodeStringIdx (NumberDecimalSeparator
) + ", ");
95 builder
.Append (EncodeStringIdx (NumberGroupSeparator
) + ", ");
97 builder
.Append (EncodeStringIdx (CurrencySymbol
) + ", ");
98 builder
.Append (EncodeStringIdx (PercentSymbol
) + ", ");
99 builder
.Append (EncodeStringIdx (NaNSymbol
) + ", ");
100 builder
.Append (EncodeStringIdx (PerMilleSymbol
) + ", ");
101 builder
.Append (EncodeStringIdx (NegativeInfinitySymbol
) + ", ");
102 builder
.Append (EncodeStringIdx (PositiveInfinitySymbol
) + ", ");
104 builder
.Append (EncodeStringIdx (NegativeSign
) + ", ");
105 builder
.Append (EncodeStringIdx (PositiveSign
) + ", ");
107 builder
.Append (CurrencyNegativePattern
+ ", ");
108 builder
.Append (CurrencyPositivePattern
+ ", ");
109 builder
.Append (PercentNegativePattern
+ ", ");
110 builder
.Append (PercentPositivePattern
+ ", ");
111 builder
.Append (NumberNegativePattern
+ ", ");
113 builder
.Append (CurrencyDecimalDigits
+ ", ");
114 builder
.Append (PercentDecimalDigits
+ ", ");
115 builder
.Append (NumberDecimalDigits
+ ", ");
117 AppendGroupSizes (builder
, CurrencyGroupSizes
);
118 builder
.Append (", ");
119 AppendGroupSizes (builder
, PercentGroupSizes
);
120 builder
.Append (", ");
121 AppendGroupSizes (builder
, NumberGroupSizes
);
123 builder
.Append ('}');
126 static void AppendGroupSizes (StringBuilder builder
, string[] gs
)
128 builder
.Append ('{');
129 for (int i
= 0; i
< gs
.Length
; i
++) {
131 builder
.Append (", ");
136 builder
.Append (gs
[i
]);
139 builder
.Append ('}');
142 public override string ToString ()
144 StringBuilder builder
= new StringBuilder ();
145 AppendTableRow (builder
);
146 return builder
.ToString ();