public static Color[] parsePalette(String value)
    {
	String val = null;
	{   int ptr = 0;
	    char[] buf = new char[value.length()];
	    for (int i = 0, n = buf.length; i < n; i++)
	    {   char c = value.charAt(i);
		if ((c != '\033') && (c != ']'))
		    if (c == ';')
			if ((i > 0) && (buf[ptr - 1] == '4'))
			    buf[ptr - 1] = '/';
			else
			    buf[ptr++] = '/';
		    else if (c == ':')
			ptr -= 3;
		    else
			buf[ptr++] = c;
	    }
	    val = (new String(buf, 0, ptr)).toUpperCase();
	}
	String defvalue = "00000001CD0000200CD003CDCD0041E90FF5CD00CD600CDCD7E5E5E5"
	                + "84C4C4C9FF0000A00FF00BFFFF00C4682B4DFF00FFE00FFFFFFFFFFF";
	Color[] palette = new Color[16];
        for (int ptr = 0, n = defvalue.length(); ptr < n; ptr += 7)
	{
	    int index = Integer.parseInt(defvalue.substring(ptr + 0, ptr + 1), 16);
	    int red   = Integer.parseInt(defvalue.substring(ptr + 1, ptr + 3), 16);
	    int green = Integer.parseInt(defvalue.substring(ptr + 3, ptr + 5), 16);
	    int blue  = Integer.parseInt(defvalue.substring(ptr + 5, ptr + 7), 16);
	    palette[index] = new Color(red, green, blue);
	}
	for (int ptr = 0, n = val.length(); ptr < n;)
	{   String v = val.substring(ptr + 1, val.indexOf('\\', ptr));
	    ptr = v.length() + 2;
	    String[] vs = v.split("/");
	    int index = Integer.parseInt(vs[0], 10);
	    int red   = Integer.parseInt(vs[1], 16);
	    int green = Integer.parseInt(vs[2], 16);
	    int blue  = Integer.parseInt(vs[3], 16);
	    palette[index] = new Color(red, green, blue);
	}
	return palette;
    }