Created
August 4, 2016 09:09
-
-
Save ParkSangGwon/c3fc35dd1072255b72b68920e7aeaae6 to your computer and use it in GitHub Desktop.
안드로이드,JAVA에서 단어에 따라서 '을/를', '이/가','은/는' 구분하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KoreanUtil { | |
public static final String getComleteWordByJongsung(String name, String firstValue, String secondValue) { | |
char lastName = name.charAt(name.length() - 1); | |
// 한글의 제일 처음과 끝의 범위밖일 경우는 오류 | |
if (lastName < 0xAC00 || lastName > 0xD7A3) { | |
return name; | |
} | |
String seletedValue = (lastName - 0xAC00) % 28 > 0 ? firstValue : secondValue; | |
return name+seletedValue; | |
} | |
} |
이 글을 보고 아이디어를 얻어 String.format 처럼 편리하게 쓸 수 있도록 만들어 봤습니다.
https://github.com/b1uec0in/AndroidJosaFormatter
블로그의 댓글(http://gun0912.tistory.com/65 )을 보고 영어나 숫자도 되도록 하긴 했는데, 정확한 규칙을 잘 모르겠네요.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
사용법
KoreanUtil.getComleteWordByJongsung("박상권","을","를")