2 // System.Globalization.CharUnicodeInfo.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
11 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 namespace System.Globalization
36 public sealed class CharUnicodeInfo
38 private CharUnicodeInfo () {}
40 public static int GetDecimalDigitValue (char ch)
44 // They are not decimal digits but are regarded as they were.
55 // They are not decimal digits but are regarded as they were.
56 if (8308 <= i && i < 8314)
58 if (8320 <= i && i < 8330)
61 if (!Char.IsDigit (ch))
114 public static int GetDecimalDigitValue (string s, int index)
117 throw new ArgumentNullException ("s");
118 return GetDecimalDigitValue (s [index]);
121 public static int GetDigitValue (char ch)
123 int i = GetDecimalDigitValue (ch);
132 // They are False in Char.IsDigit(), but returns a digit
133 if (i >= 9312 && i < 9321)
135 if (i >= 9332 && i < 9341)
137 if (i >= 9352 && i < 9361)
139 if (i >= 9461 && i < 9470)
141 if (i >= 10102 && i < 10111)
143 if (i >= 10112 && i < 10121)
145 if (i >= 10122 && i < 10131)
151 public static int GetDigitValue (string s, int index)
154 throw new ArgumentNullException ("s");
155 return GetDigitValue (s [index]);
158 public static double GetNumericValue (char ch)
160 int i = GetDigitValue (ch);
237 case 9470: // IsNumber(c) is False BTW.
252 // They are not True by IsNumber() but regarded as they were.
253 if (9451 <= i && i < 9461)
255 if (12321 <= i && i < 12330)
257 if (12881 <= i && i < 12896)
259 if (12977 <= i && i < 12992)
262 if (!char.IsNumber (ch))
266 return 0.5 + i - 3882;
268 return (i - 4977) * 10;
270 return 0.2 * (i - 8532);
291 public static double GetNumericValue (string s, int index)
294 throw new ArgumentNullException ("s");
295 return GetNumericValue (s [index]);
298 public static UnicodeCategory GetUnicodeCategory (char ch)
300 return Char.GetUnicodeCategory (ch);
303 public static UnicodeCategory GetUnicodeCategory (string s, int index)
306 throw new ArgumentNullException ("s");
307 return Char.GetUnicodeCategory (s, index);