Fix eglibc remapping and revive the test for its completeness. (#4896)
[mono-project.git] / tools / locale-builder / NumberFormatEntry.cs
blobd52a3ad4811f1bb232b559a26af5004ea9192fa1
1 //
2 // DateTimeFormatEntry.cs
3 //
4 // Authors:
5 // Jackson Harper (jackson@ximian.com)
6 // Marek Safar <marek.safar@gmail.com>
7 //
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.
31 using System.Text;
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;
53 public int PercentDecimalDigits;
54 public string PercentDecimalSeparator = ",";
55 public string PercentGroupSeparator = ",";
56 public string[] PercentGroupSizes = new string[Constants.GROUP_SIZE];
58 public string PercentNegativePattern;
59 public string PercentPositivePattern;
60 public string PercentSymbol = "%";
61 public string PerMilleSymbol = "‰";
62 public string InfinitySymbol = "Infinity";
63 public string PositiveSign = "+";
64 public DigitShapes DigitSubstitution = DigitShapes.None;
65 public string[] NativeDigits = new string[10] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
67 public int Row;
69 public string NegativeInfinitySymbol
71 get
73 if (InfinitySymbol.StartsWith (PositiveSign))
74 return NegativeSign + InfinitySymbol.Substring (1, InfinitySymbol.Length - 1);
76 return NegativeSign + InfinitySymbol;
80 public string PositiveInfinitySymbol
82 get
84 return InfinitySymbol;
88 public void AppendTableRow (StringBuilder builder)
90 builder.Append ("\t{");
92 builder.Append (EncodeStringIdx (CurrencyDecimalSeparator) + ", ");
93 builder.Append (EncodeStringIdx (CurrencyGroupSeparator) + ", ");
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 (NumberDecimalDigits + ", ");
116 AppendGroupSizes (builder, CurrencyGroupSizes);
117 builder.Append (", ");
118 AppendGroupSizes (builder, NumberGroupSizes);
120 builder.Append ('}');
123 static void AppendGroupSizes (StringBuilder builder, string[] gs)
125 builder.Append ('{');
126 for (int i = 0; i < gs.Length; i++) {
127 if (i > 0)
128 builder.Append (", ");
130 if (gs[i] == null)
131 builder.Append (-1);
132 else
133 builder.Append (gs[i]);
136 builder.Append ('}');
139 public override string ToString ()
141 StringBuilder builder = new StringBuilder ();
142 AppendTableRow (builder);
143 return builder.ToString ();