Percent-decodes the given string.

@param str the string to decode
@param firstPercent the index of the first '%' character in the string
@return the decoded string
489600
private static String decode(final String str, final int firstPercent) {
        StringBuilder builder = new StringBuilder();
        builder.append(str.substring(0, firstPercent));

        appendDecoded(builder, str, firstPercent);

        for (int i = firstPercent + 3; i < str.length(); ++i) {
            if (str.charAt(i) == '%') {
                appendDecoded(builder, str, i);
                i += 2;
            } else {
                builder.append(str.charAt(i));
            }
        }

        return builder.toString();
    }
261920
protected static String getPartialStartedWord(String str, int pos){
		assert(pos < str.length() && pos >= 0);

		if(	posIsAtWord(str, pos) ){
			int nextSpace = findNextNonLetterOrDigit(str, pos);
			if(nextSpace == -1){
				nextSpace = str.length();
			}
			
			return str.substring(pos, nextSpace);
		}
		return null;
	}
135244
function formatPercent(value, locale, digitsInfo) {
    var format = getLocaleNumberFormat(locale, NumberFormatStyle.Percent);
    var pattern = parseNumberFormat(format, getLocaleNumberSymbol(locale, NumberSymbol.MinusSign));
    var res = formatNumberToLocaleString(value, pattern, locale, NumberSymbol.Group, NumberSymbol.Decimal, digitsInfo, true);
    return res.replace(new RegExp(PERCENT_CHAR, 'g'), getLocaleNumberSymbol(locale, NumberSymbol.PercentSign));
}
1246806
def percentage=(percentage)

      if !percentage.nil? && percentage.to_s.length > 10
        fail ArgumentError, "invalid value for 'percentage', the character length must be smaller than or equal to 10."
      end

      @percentage = percentage
    end
307326
private double calcEntropy(String str) {

    HashMap<Character, Integer> freq = new HashMap<>();
    for (int i = 0; i < str.length(); i++) {
      char c = str.charAt(i);
      Integer count = freq.get(c);
      if (count == null) freq.put(c, 1);
      else freq.put(c, count + 1);
    }
    double sume = 0;
    int N = str.length();
    double n;
    for (char c : freq.keySet()) {
      n = freq.get(c);
      sume += -n / N * Math.log(n / N) / Math.log(2);
    }
    return sume;
  }
1363147
public static function mb_similar_text($str1, $str2, &$percent = null)
    {
        if (0 === mb_strlen($str1) + mb_strlen($str2)) {
            $percent = 0.0;

            return 0;
        }

        $pos1 = $pos2 = $max = 0;
        $l1 = mb_strlen($str1);
        $l2 = mb_strlen($str2);

        for ($p = 0; $p < $l1; ++$p) {
            for ($q = 0; $q < $l2; ++$q) {
                for ($l = 0; ($p + $l < $l1) && ($q + $l < $l2) && mb_substr($str1, $p + $l, 1) === mb_substr($str2, $q + $l, 1); ++$l) {
                    // nothing to do
                }
                if ($l > $max) {
                    $max = $l;
                    $pos1 = $p;
                    $pos2 = $q;
                }
            }
        }

        $similarity = $max;
        if ($similarity) {
            if ($pos1 && $pos2) {
                $similarity += self::mb_similar_text(mb_substr($str1, 0, $pos1), mb_substr($str2, 0, $pos2));
            }
            if (($pos1 + $max < $l1) && ($pos2 + $max < $l2)) {
                $similarity += self::mb_similar_text(
                    mb_substr($str1, $pos1 + $max, $l1 - $pos1 - $max),
                    mb_substr($str2, $pos2 + $max, $l2 - $pos2 - $max)
                );
            }
        }

        $percent = ($similarity * 200.0) / ($l1 + $l2);

        return $similarity;
    }
109333
public static boolean isDecimal(String str, int beginIndex, int endIndex)
    {
        if ( str.charAt(str.length() - 1) == '.'
                || str.charAt(0) == '.' ) {
            return false;
        }

        char c;
        int p= 0;        //number of point
        for ( int j = 1; j < str.length(); j++ ) {
            c = str.charAt(j);
            if ( c == '.' ) {
                p++;
            } else {
                //make full-width half-width
                if ( c > 65280 ) c -= 65248;
                if ( c < 48 || c > 57 ) return false;
            }
        }

        return (p==1);
    }
51633
public static String percentFrom(final double a, final double b)
	{

		double bVal = b;

		if (bVal == 0.) {
			bVal = 1.;
		}

		StringBuilder rep = new StringBuilder();
		double d = ((long) ((a / bVal) * 10000) / 100.);
		if (d < 10.0) {
			rep.append('0');
		}

		rep.append(d);
		while (rep.length() < 5) {
			rep.append('0');
		}

		return rep + "%";
	}
883878
private static String intPart(String str) {
        return str.indexOf(JAVA_DECIMAL_POINT) > 0 ? str.substring(0,
                str.indexOf(JAVA_DECIMAL_POINT)) : str;
    }
442970
private static String decodeUrl(final String url) {
        String decoded = url;
        if (url != null && url.indexOf('%') >= 0) {
            final int n = url.length();
            final StringBuffer buffer = new StringBuffer();
            final ByteBuffer bytes = ByteBuffer.allocate(n);
            for (int i = 0; i < n;) {
                if (url.charAt(i) == '%') {
                    try {
                        do {
                            final byte octet = (byte) Integer.parseInt(url.substring(i + 1, i + 3), 16);
                            bytes.put(octet);
                            i += 3;
                        } while (i < n && url.charAt(i) == '%');
                        continue;
                    } catch (final RuntimeException e) {
                        // malformed percent-encoded octet, fall through and
                        // append characters literally
                    } finally {
                        if (bytes.position() > 0) {
                            bytes.flip();
                            buffer.append(Charsets.UTF_8.decode(bytes).toString());
                            bytes.clear();
                        }
                    }
                }
                buffer.append(url.charAt(i++));
            }
            decoded = buffer.toString();
        }
        return decoded;
    }
1122680
public static String decodeString(String str) {
		try {
			return new String(Base64.decode(str));
		} catch (IOException io) {
			throw new RuntimeException(io.getMessage(), io.getCause());
		}
	}
1147746
private String formatPercentage(Number value)
   {
      return (value == null ? null : m_formats.getPercentageDecimalFormat().format(value) + "%");
   }
666955
private static void percentEncode(Writer writer, char c, String characterEncoding) throws IOException
    {
        String app = null;
        if (c > (char)((short)0x007F))
        {
            //percent encode in the proper encoding to be consistent
            //app = percentEncodeNonUsAsciiCharacter(writer c, characterEncoding);
            percentEncodeNonUsAsciiCharacter(writer, c, characterEncoding);
        }
        else
        {
            //percent encode US-ASCII char (0x00-0x7F range)
            //app = "%" + HEX_CHARSET.charAt( ((c >> 0x4) % 0x10)) +HEX_CHARSET.charAt(c % 0x10);
            writer.write('%');
            writer.write(HEX_CHARSET.charAt( ((c >> 0x4) % 0x10)));
            writer.write(HEX_CHARSET.charAt(c % 0x10));
        }
        //return app;
    }
238767
def percent
      return unless (buffer = accept_stripped :exp_percent)
      match_start = buffer[-1]
      match_name = :"percent#{match_start}"

      unless Tokens[match_name]
        match_end = Tokens.bracket(match_start) || match_start

        match_inner = "\\#{match_start}"
        match_inner += "\\#{match_end}" unless match_end == match_start

        pattern = /(((?:[^#{match_inner}\\]|\\.)*?)#{'\\' + match_end})/

        Tokens[match_name] = pattern
      end

      buffer += accept match_name
      buffer
    end
837230
public static char eatPercentage(String a, int[] n) {
    // Length 0
    if (!a.startsWith("%") || a.length() < 3) {
      n[0] = 0;
      return ((char) 0);
    }
    char c;
    // Try to parse first char
    try {
      c = (char) Integer.parseInt(a.substring(1, 3), 16);
    } catch (Exception e) {
      n[0] = -1;
      return ((char) 0);
    }
    // For non-UTF8, return the char    
    int len = Utf8Length(c);
    n[0] = 3;
    if (len <= 1) return (c);
    // Else collect the UTF8
    String dec = "" + c;
    for (int i = 1; i < len; i++) {
      try {
        dec += (char) Integer.parseInt(a.substring(1 + i * 3, 3 + i * 3), 16);
      } catch (Exception e) {
        return (c);
      }
    }
    // Try to decode the UTF8
    int[] eatLength = new int[1];
    char utf8 = eatUtf8(dec, eatLength);
    if (eatLength[0] != len) return (c);
    n[0] = len * 3;
    return (utf8);
  }
79776
protected static String decodePercent(String str) {
        String decoded = null;
        try {
            decoded = URLDecoder.decode(str, "UTF8");
        } catch (UnsupportedEncodingException ignored) {
            NanoHTTPD.LOG.log(Level.WARNING, "Encoding not supported, ignored", ignored);
        }
        return decoded;
    }
52060
def percentage(value: str) -> float:
    
    try:
        fvalue = float(value)
        assert 0 <= fvalue <= 100
    except (AssertionError, TypeError, ValueError):
        raise ArgumentTypeError(
            "{!r} is an invalid percentage value".format(value))
    return fvalue