Center string.

@param s      the s
@param length the length
@return the string
197321
public static String center(String s, int length) {
      if (s == null) {
         return null;
      }
      int start = (int) Math.floor(Math.max(0, (length - s.length()) / 2d));
      return padEnd(repeat(' ', start) + s, length, ' ');
   }
458922
protected final void putString(String s) {
        ensureCapacity(position + (s.length() * 2) + 1);

        System.arraycopy(s.getBytes(), 0, buffer, position, s.length());
        position += s.length();
        buffer[position++] = 0;
    }
314939
public static String stripSpaces(String s)
    {
        StringBuffer buff = new StringBuffer();
        for(int i = 0; i < s.length(); i++)
        {
            char c = s.charAt(i);
            if(c != ' ')
                buff.append(c);
        }
        return buff.toString();
    }
1033992
public static String toObnString(String s) {
        if (s != null && !s.isEmpty())
            return s.replace(':', '.').replace('=', '.').replace(',', '.').replace('"', '.');
        return s;
    }
1122407
@Override
    public String getString(long start, int length)
    {
        if (length == 0)
        {
            return "";
        }
        if (array != null)
        {
            int ps = (int) (start % size);
            int es = (int) ((start+length) % size);
            if (ps < es)
            {
                return new String(array, ps, length);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.append(array, ps, size-ps);
                sb.append(array, 0, es);
                return sb.toString();
            }
        }
        else
        {
            StringBuilder sb = new StringBuilder();
            for (int ii=0;ii<length;ii++)
            {
                sb.append((char)get(start+ii));
            }
            return sb.toString();
        }
    }
461415
public static boolean endWith(@Nullable CharSequence s, char c) {
		if (StringUtils.isEmpty(s)) {
			return false;
		}
		return s.charAt(s.length() - 1) == c;
	}
976672
public void encodeString(final String s) throws IOException {
		final int lenChars = s.length();
		final int lenCharacters = s.codePointCount(0, lenChars);
		encodeUnsignedInteger(lenCharacters);
		encodeStringOnly(s);
	}
1071050
public static String capitalize (String s)
    {
        if (isBlank(s)) {
            return s;
        }
        char c = s.charAt(0);
        if (Character.isUpperCase(c)) {
            return s;
        } else {
            return String.valueOf(Character.toUpperCase(c)) + s.substring(1);
        }
    }
468993
def center_str(txt, font_name, font_size, offset=0):
    """"""
    return -(text_width(txt, font_name, font_size) / 2.0) + offset
1310910
public static String getStrCode(int length) {
        StringBuffer str = new StringBuffer();
        while (str.length() <= length - 1)
            str.append(strArray[new Random().nextInt(strArray.length)]);
        return str.toString();
    }
651634
static String normalize(String s) {
        StringBuilder sb = new StringBuilder();
        boolean changed = false;
        boolean lastCharWasWS = false;
        final int len = s.length();
        for (int i = 0; i < len; i++) {
            char c = s.charAt(i);
            if (Character.isWhitespace(c)) {
                if (!lastCharWasWS) {
                    sb.append(SPACE);
                    changed |= c != SPACE;
                } else {
                    changed = true;
                }
                lastCharWasWS = true;
            } else {
                sb.append(c);
                lastCharWasWS = false;
            }
        }
        return changed ? sb.toString() : s;
    }
744250
protected String rtrim(String s)
    {
        if (s == null || s.length() == 0)
        {
            return s;
        }

        int pos = s.length();

        while (pos > 0 && Character.isWhitespace(s.charAt(pos - 1)))
        {
            --pos;
        }

        return s.substring(0, pos);
    }
651037
public static String asterisked(String str, int keepSize, boolean keepStart) {
		if (StringUtils.isBlank(str)) return "";
		
		int length = str.length();
		if (length < keepSize) return str;
		if (keepSize < 1) return getAsterisks(length);
		
		int notKeepSize = length - keepSize;
		String keep;
		if (keepStart) {
			keep = str.substring(0, keepSize);
			return keep + getAsterisks(notKeepSize);
		} else {
			keep = str.substring(notKeepSize);
			return getAsterisks(notKeepSize) + keep;
		}
	}
618238
public static String capitalize(String s)
    {
        if (s == null || s.length() == 0)
        {
            return s;
        }
        char chars[] = s.toCharArray();
        chars[0] = Character.toUpperCase(chars[0]);
        return new String(chars);
    }
939312
public static String quote(String s) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            buf.append(quote(s.charAt(i)));
        }
        return buf.toString();
    }
30628
def center_num(self, string):
        
        l = 0
        for i in string:
            l += 2 if self.is_cn_char(i) else 1
        return l
47510
function (expr, length, fillChar) {
  fillChar = fillChar || ' ';
  var string = '' + expr;
  var totalPad = length - string.length;
  if (string.length > length) {
    return center(string, length);
  } else {
    //if (totalPad > 0) {
      var leftPad = string.length + Math.floor(totalPad / 2);
      string = lpad(string, leftPad, fillChar);
      string = rpad(string, length, fillChar);
    //}
  }
  return string;
}