Here you can find the source of toUpperCaseAscii(String s)
Parameter | Description |
---|---|
s | a string. |
public static String toUpperCaseAscii(String s)
//package com.java2s; public class Main { /**/*from w ww. j a v a 2 s.c o m*/ * Returns a string with all ASCII lower-case letters * converted to upper-case. * * @param s a string. */ public static String toUpperCaseAscii(String s) { if (s == null) return null; int len = s.length(); char c = 0; boolean hasLowerCase = false; for (int i = 0; i < len; i++) { c = s.charAt(i); if (c >= 'a' && c <= 'z') { hasLowerCase = true; break; } } if (!hasLowerCase) return s; StringBuilder builder = new StringBuilder(); for (int i = 0; i < len; i++) { c = s.charAt(i); if (c >= 'a' && c <= 'z') { builder.append((char) (c - 0x20)); } else { builder.append(c); } } return builder.toString(); } }