Skip to content

Instantly share code, notes, and snippets.

@cackyhk
Forked from ParkSangGwon/KoreanUtil.java
Created August 4, 2016 12:40
Show Gist options
  • Select an option

  • Save cackyhk/7c969480fbb20e5a4de0872dbc2643bc to your computer and use it in GitHub Desktop.

Select an option

Save cackyhk/7c969480fbb20e5a4de0872dbc2643bc to your computer and use it in GitHub Desktop.
안드로이드,JAVA에서 단어에 따라서 '을/를', '이/가','은/는' 구분하기
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment