return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
- private static bool ParseFormat (string format, out char specifier, out int precision)
+ private static bool ParseFormat (string format, out char specifier, out int precision, out bool custom)
{
precision = -1;
specifier = '\0';
+ custom = false;
int length = format.Length;
// TODO: Could an empty string be a custom format string?
}
// We've got a custom format string.
- specifier = 'z';
+ custom = true;
return true;
}
{
char specifier;
int precision;
-
- if (!ParseFormat (format, out specifier, out precision))
+ bool custom;
+
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this instance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
{
char specifier;
int precision;
+ bool custom;
- if (!ParseFormat (format, out specifier, out precision))
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this insance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
{
char specifier;
int precision;
+ bool custom;
- if (!ParseFormat (format, out specifier, out precision))
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
+
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'C': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this instance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
{
char specifier;
int precision;
+ bool custom;
- if (!ParseFormat (format, out specifier, out precision))
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
+
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'C': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this instance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
{
char specifier;
int precision;
+ bool custom;
- if (!ParseFormat (format, out specifier, out precision))
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
+
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'C': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this instance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
{
char specifier;
int precision;
+ bool custom;
- if (!ParseFormat (format, out specifier, out precision))
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
+
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'C': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this instance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
{
char specifier;
int precision;
+ bool custom;
- if (!ParseFormat (format, out specifier, out precision))
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
+
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'C': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this instance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
{
char specifier;
int precision;
+ bool custom;
- if (!ParseFormat (format, out specifier, out precision))
+ if (!ParseFormat (format, out specifier, out precision, out custom))
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
+ if (custom){
+ return FormatCustom (format, value, nfi);
+ }
+
switch(specifier) {
case 'c': return FormatCurrency (value, precision, nfi);
case 'C': return FormatCurrency (value, precision, nfi);
case 'R': throw new FormatException (Locale.GetText ("The specified format cannot be used in this instance"));
case 'x': return FormatHexadecimal (value, precision, false);
case 'X': return FormatHexadecimal (value, precision, true);
- case 'z': return FormatCustom (format, value, nfi);
default:
throw new FormatException (Locale.GetText ("The specified format '" + format + "' is invalid"));
}
// discarded.
//
- private static string FormatGeneral (byte value, int precision, NumberFormatInfo nfi, bool upper) {
+ internal static string FormatGeneral (byte value, int precision, NumberFormatInfo nfi, bool upper) {
return FormatGeneral ((uint)value, precision, nfi, upper);
}
- private static string FormatGeneral (short value, int precision, NumberFormatInfo nfi, bool upper) {
+ internal static string FormatGeneral (short value, int precision, NumberFormatInfo nfi, bool upper) {
return FormatGeneral ((int)value, precision, nfi, upper);
}
- private static string FormatGeneral (int value, int precision, NumberFormatInfo nfi, bool upper)
+ internal static string FormatGeneral (int value, int precision, NumberFormatInfo nfi, bool upper)
{
bool negative = (value < 0);
char[] tmp = new char [maxIntLength];
return new string (buffy, 0, position);
}
- private static string FormatGeneral (long value, int precision, NumberFormatInfo nfi, bool upper)
+ internal static string FormatGeneral (long value, int precision, NumberFormatInfo nfi, bool upper)
{
bool negative = (value < 0);
char[] tmp = new char [maxLongLength];
return new string (buffy, 0, position);
}
- private static string FormatGeneral (sbyte value, int precision, NumberFormatInfo nfi, bool upper) {
+ internal static string FormatGeneral (sbyte value, int precision, NumberFormatInfo nfi, bool upper) {
return FormatGeneral ((int)value, precision, nfi, upper);
}
- private static string FormatGeneral (ushort value, int precision, NumberFormatInfo nfi, bool upper) {
+ internal static string FormatGeneral (ushort value, int precision, NumberFormatInfo nfi, bool upper) {
return FormatGeneral ((uint)value, precision, nfi, upper);
}
- private static string FormatGeneral (uint value, int precision, NumberFormatInfo nfi, bool upper)
+ internal static string FormatGeneral (uint value, int precision, NumberFormatInfo nfi, bool upper)
{
char[] tmp = new char [maxIntLength];
int exponent = 0;
return new string (buffy, 0, position);
}
- private static string FormatGeneral (ulong value, int precision, NumberFormatInfo nfi, bool upper)
+ internal static string FormatGeneral (ulong value, int precision, NumberFormatInfo nfi, bool upper)
{
char[] tmp = new char [maxLongLength];
int exponent = 0;
type = sec.TokenTypes [tokidx];
if (type == PH_0 || type == PH_NUMBER) {
//FIXME: PH_NUMBER should also check for significant digits
- Console.WriteLine ("group : {0}", group);
+ // Console.WriteLine ("group : {0}", group);
int i = sec.tokens [tokidx].Length - 1;
while (i >= 0) {
if (insertComma && group == 3) {
if (signValue == 0 && nsections > 1)
section = 2;
+ if (number [0] == '-')
+ number = number.Substring (1);
+
FormatSection sec = sections [section];
digits = AdjustDigits (number.ToString (), sec);
if (digits.Length == 1 && digits [0] == '0')