주소록 대량등록 치환문자 바이트수 계산로직 수정
This commit is contained in:
parent
68eda9ff2c
commit
b51956b8d9
@ -1663,6 +1663,7 @@ public class AddrController {
|
||||
//String phoneRegExp = "^01(?:0|1|[6-9])[.-]?(\\d{3}|\\d{4})[.-]?(\\d{4})$";
|
||||
String phoneRegExp = "^(050[234567]{1}|01[016789]{1})-?[0-9]{3,4}-?[0-9]{4}$";
|
||||
|
||||
String charset = "euc-kr";
|
||||
boolean isSuccess = true;
|
||||
String msg = "";
|
||||
int resultCnt = 0;
|
||||
@ -1734,14 +1735,14 @@ public class AddrController {
|
||||
tempAddrVO.setAddrNm(null);
|
||||
}else {
|
||||
String tmpNm = addrVO.getNameList()[i].trim().replaceAll("§", ",");
|
||||
int nmLen = tmpNm.length();
|
||||
int nmLen = tmpNm.getBytes(charset).length;
|
||||
|
||||
if(nmLen > 12) {
|
||||
if(nmLen >= 20) {
|
||||
//isSuccess = false;
|
||||
//msg = "이름 항목의 내용(\" " + tmpNm + " \")이 길이를 초과하여 입력되었습니다. 12글자 이하로 입력해 주세요.";
|
||||
//break;
|
||||
|
||||
tempAddrVO.setAddrNm(addrVO.getNameList()[i].trim().replaceAll("§", ",").substring(0, 12));
|
||||
tempAddrVO.setAddrNm(subStringBytes(addrVO.getNameList()[i].replaceAll("§", ","), 20, 2));
|
||||
}else {
|
||||
tempAddrVO.setAddrNm(addrVO.getNameList()[i].trim().replaceAll("§", ","));
|
||||
}
|
||||
@ -1769,14 +1770,13 @@ public class AddrController {
|
||||
}else {
|
||||
|
||||
String tmpInfo1 = addrVO.getInfo1List()[i].replaceAll("§", ",");
|
||||
int info1Len = tmpInfo1.length();
|
||||
int info1Len = tmpInfo1.getBytes(charset).length;
|
||||
|
||||
if(info1Len > 20) {
|
||||
if(info1Len >= 40) {
|
||||
//isSuccess = false;
|
||||
//msg = "[*1*] 항목의 내용(\" " + tmpInfo1 + " \")이 길이를 초과하여 입력되었습니다. 20글자 이하로 입력해 주세요.";
|
||||
//break;
|
||||
|
||||
tempAddrVO.setAddrInfo1(addrVO.getInfo1List()[i].replaceAll("§", ",").substring(0, 20));
|
||||
tempAddrVO.setAddrInfo1(subStringBytes(addrVO.getInfo1List()[i].replaceAll("§", ","), 40, 2));
|
||||
}else {
|
||||
tempAddrVO.setAddrInfo1(addrVO.getInfo1List()[i].replaceAll("§", ","));
|
||||
}
|
||||
@ -1791,14 +1791,14 @@ public class AddrController {
|
||||
tempAddrVO.setAddrInfo2(null);
|
||||
}else {
|
||||
String tmpInfo2 = addrVO.getInfo2List()[i].replaceAll("§", ",");
|
||||
int info2Len = tmpInfo2.length();
|
||||
int info2Len = tmpInfo2.getBytes(charset).length;
|
||||
|
||||
if(info2Len > 20) {
|
||||
if(info2Len >= 40) {
|
||||
//isSuccess = false;
|
||||
//msg = "[*2*] 항목의 내용(\" " + tmpInfo2 + " \")이 길이를 초과하여 입력되었습니다. 20글자 이하로 입력해 주세요.";
|
||||
//break;
|
||||
|
||||
tempAddrVO.setAddrInfo2(addrVO.getInfo2List()[i].replaceAll("§", ",").substring(0, 20));
|
||||
tempAddrVO.setAddrInfo2(subStringBytes(addrVO.getInfo2List()[i].replaceAll("§", ","), 40, 2));
|
||||
}else {
|
||||
tempAddrVO.setAddrInfo2(addrVO.getInfo2List()[i].replaceAll("§", ","));
|
||||
}
|
||||
@ -1814,14 +1814,14 @@ public class AddrController {
|
||||
tempAddrVO.setAddrInfo3(null);
|
||||
}else {
|
||||
String tmpInfo3 = addrVO.getInfo3List()[i].replaceAll("§", ",");
|
||||
int info3Len = tmpInfo3.length();
|
||||
int info3Len = tmpInfo3.getBytes(charset).length;
|
||||
|
||||
if(info3Len > 20) {
|
||||
if(info3Len >= 40) {
|
||||
//isSuccess = false;
|
||||
//msg = "[*3*] 항목의 내용(\" " + tmpInfo3 + " \")이 길이를 초과하여 입력되었습니다. 20글자 이하로 입력해 주세요.";
|
||||
//break;
|
||||
|
||||
tempAddrVO.setAddrInfo3(addrVO.getInfo3List()[i].replaceAll("§", ",").substring(0, 20));
|
||||
tempAddrVO.setAddrInfo3(subStringBytes(addrVO.getInfo3List()[i].replaceAll("§", ","), 40, 2));
|
||||
}else {
|
||||
tempAddrVO.setAddrInfo3(addrVO.getInfo3List()[i].replaceAll("§", ","));
|
||||
}
|
||||
@ -1836,14 +1836,14 @@ public class AddrController {
|
||||
tempAddrVO.setAddrInfo4(null);
|
||||
}else {
|
||||
String tmpInfo4 = addrVO.getInfo4List()[i].replaceAll("§", ",");
|
||||
int info4Len = tmpInfo4.length();
|
||||
int info4Len = tmpInfo4.getBytes(charset).length;
|
||||
|
||||
if(info4Len > 20) {
|
||||
if(info4Len >= 40) {
|
||||
//isSuccess = false;
|
||||
//msg = "[*4*] 항목의 내용(\" " + tmpInfo4 + " \")이 길이를 초과하여 입력되었습니다. 20글자 이하로 입력해 주세요.";
|
||||
//break;
|
||||
|
||||
tempAddrVO.setAddrInfo4(addrVO.getInfo4List()[i].replaceAll("§", ",").substring(0, 20));
|
||||
tempAddrVO.setAddrInfo4(subStringBytes(addrVO.getInfo4List()[i].replaceAll("§", ","), 40, 2));
|
||||
}else {
|
||||
tempAddrVO.setAddrInfo4(addrVO.getInfo4List()[i].replaceAll("§", ","));
|
||||
}
|
||||
@ -1858,14 +1858,14 @@ public class AddrController {
|
||||
tempAddrVO.setAddrComment(null);
|
||||
}else {
|
||||
String tmpComment = addrVO.getMemoList()[i].replaceAll("§", ",");
|
||||
int commLen = tmpComment.length();
|
||||
int commLen = tmpComment.getBytes(charset).length;
|
||||
|
||||
if(commLen > 125) {
|
||||
if(commLen >= 200) {
|
||||
//isSuccess = false;
|
||||
//msg = "메모 항목의 내용(\" " + tmpComment + " \")이 길이를 초과하여 입력되었습니다. 100글자 이하로 입력해 주세요.";
|
||||
//break;
|
||||
|
||||
tempAddrVO.setAddrComment(addrVO.getMemoList()[i].replaceAll("§", ",").substring(0, 125));
|
||||
tempAddrVO.setAddrComment(subStringBytes(addrVO.getMemoList()[i].replaceAll("§", ","), 200, 2));
|
||||
}else {
|
||||
tempAddrVO.setAddrComment(addrVO.getMemoList()[i].replaceAll("§", ","));
|
||||
}
|
||||
@ -1952,6 +1952,41 @@ public class AddrController {
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
/* 바이트 자르기
|
||||
UTF-8일 경우
|
||||
subStringBytes("블라블라블라라", 10, 3);
|
||||
EUC-KR일 경우
|
||||
subStringBytes("블라블라블라라", 10, 2);
|
||||
*/
|
||||
public String subStringBytes(String str, int byteLength, int sizePerLetter) {
|
||||
int retLength = 0;
|
||||
int tempSize = 0;
|
||||
int asc;
|
||||
if (str == null || "".equals(str) || "null".equals(str)) {
|
||||
str = "";
|
||||
}
|
||||
|
||||
int length = str.length();
|
||||
|
||||
for (int i = 1; i <= length; i++) {
|
||||
asc = (int) str.charAt(i - 1);
|
||||
if (asc > 127) {
|
||||
if (byteLength >= tempSize + sizePerLetter) {
|
||||
tempSize += sizePerLetter;
|
||||
retLength++;
|
||||
}
|
||||
} else {
|
||||
if (byteLength > tempSize) {
|
||||
tempSize++;
|
||||
retLength++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return str.substring(0, retLength);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 주소록 그룹 목록
|
||||
|
||||
Loading…
Reference in New Issue
Block a user