username: webstorm |
key |
===== LICENSE BEGIN ===== |
72149-12042010 |
00000cI5EYta7xt""jWOIDohDqQx7S |
SSsCH4oSb"1Y4edvtuSYyQ"iqGYhuo |
!8r1Zrqkj"TmWPZ!Eu"puCi6KV2SVe |
===== LICENSE END ===== |
30 tháng 5, 2014
Webstorm Key
22 tháng 5, 2014
Java bỏ dấu chuổi tiếng việt
public static final String SPECIAL_CHARACTERS_TEMP = "àÀảẢãÃáÁạẠăĂằẰẳẲẵẴắẮặẶâÂầẦẩẨẫẪấẤậẬđĐèÈẻẺẽẼéÉẹẸêÊềỀểỂễỄếẾệỆìÌỉỈĩĨíÍịỊòÒỏỎõÕóÓọỌôÔồỒổỔỗỖốỐộỘơƠờỜởỞỡỠớỚợỢùÙủỦũŨúÚụỤưƯừỪửỬữỮứỨựỰýÝ :+\\<>\"*,!?%$=@#~[]`|^";
public static final String REPLACEMENTS_TEMP = "aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAdDeEeEeEeEeEeEeEeEeEeEeEiIiIiIiIiIoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOuUuUuUuUuUuUuUuUuUuUuUyY-___\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
public static char[] SPECIAL_CHARACTERS = SPECIAL_CHARACTERS_TEMP
.toCharArray();
public static char[] REPLACEMENTS = REPLACEMENTS_TEMP.toCharArray();
public static String toUrlFriendly(String s) {
int maxLength = Math.min(s.length(), 236);
char[] buffer = new char[maxLength];
int n = 0;
for (int i = 0; i < maxLength; i++) {
char ch = s.charAt(i);
buffer[n] = removeAccent(ch);
// skip not printable characters
if (buffer[n] > 31) {
n++;
}
}
// skip trailing slashes
while (n > 0 && buffer[n - 1] == '/') {
n--;
}
return String.valueOf(buffer, 0, n);
}
public static char removeAccent(char ch) {
int index = SPECIAL_CHARACTERS_TEMP.indexOf(ch);
if (index >= 0) {
ch = REPLACEMENTS[index];
}
return ch;
}
public static String removeAccent(String s) {
StringBuilder sb = new StringBuilder(s);
for (int i = 0; i < sb.length(); i++) {
sb.setCharAt(i, removeAccent(sb.charAt(i)));
}
return sb.toString();
}
public static final String REPLACEMENTS_TEMP = "aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAdDeEeEeEeEeEeEeEeEeEeEeEiIiIiIiIiIoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOuUuUuUuUuUuUuUuUuUuUuUyY-___\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
public static char[] SPECIAL_CHARACTERS = SPECIAL_CHARACTERS_TEMP
.toCharArray();
public static char[] REPLACEMENTS = REPLACEMENTS_TEMP.toCharArray();
public static String toUrlFriendly(String s) {
int maxLength = Math.min(s.length(), 236);
char[] buffer = new char[maxLength];
int n = 0;
for (int i = 0; i < maxLength; i++) {
char ch = s.charAt(i);
buffer[n] = removeAccent(ch);
// skip not printable characters
if (buffer[n] > 31) {
n++;
}
}
// skip trailing slashes
while (n > 0 && buffer[n - 1] == '/') {
n--;
}
return String.valueOf(buffer, 0, n);
}
public static char removeAccent(char ch) {
int index = SPECIAL_CHARACTERS_TEMP.indexOf(ch);
if (index >= 0) {
ch = REPLACEMENTS[index];
}
return ch;
}
public static String removeAccent(String s) {
StringBuilder sb = new StringBuilder(s);
for (int i = 0; i < sb.length(); i++) {
sb.setCharAt(i, removeAccent(sb.charAt(i)));
}
return sb.toString();
}
Đăng ký:
Bài đăng (Atom)