|
|
@@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
|
|
|
import android.telephony.PhoneNumberUtils;
|
|
|
import android.text.Html;
|
|
|
import android.text.Spanned;
|
|
|
+import android.util.Log;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.security.MessageDigest;
|
|
|
@@ -817,7 +818,8 @@ public class StringUtil {
|
|
|
*/
|
|
|
public static String checkName(String name) {
|
|
|
if (!StringUtil.isEmpty(name)) {
|
|
|
- if(name.getBytes().length > 20) {
|
|
|
+ if(StringUtil.getByteLength(name) > 20) {
|
|
|
+// if(name.getBytes().length > 20) {
|
|
|
return "한글 10자, 영문 20자까지 입력 가능합니다.";
|
|
|
} else {
|
|
|
return "";
|
|
|
@@ -837,4 +839,22 @@ public class StringUtil {
|
|
|
String regexStr = "^[0-9]*$";
|
|
|
return str.matches(regexStr);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 문자열의 바이트 길이
|
|
|
+ * 인코딩 문자셋에 따라 바이트 길이 달라짐
|
|
|
+ *
|
|
|
+ * @param str
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static int getByteLength(String str) {
|
|
|
+ if (str != null) {
|
|
|
+ try {
|
|
|
+ return str.getBytes("KSC5601").length;
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+// Log.e(getClass().getSimpleName(), "UnsupportedEncodingException");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
}
|