Created
September 5, 2017 16:51
-
-
Save sh-cho/aff7f56c0e48994c3560eb7d69337b06 to your computer and use it in GitHub Desktop.
is contain hangul?
This file contains hidden or 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
#include <stdio.h> | |
#include <wchar.h> //wcslen | |
int is_contain_hangul(const wchar_t *str) { | |
const size_t len = wcslen(str); | |
const wchar_t start_ch = L'가'; | |
const wchar_t end_ch = L'힣'; | |
register int i; | |
for (i = 0; i < len; ++i) { | |
if (str[i] >= start_ch && str[i] <= end_ch) | |
return 1; | |
} | |
return 0; | |
} | |
int main() { | |
wchar_t *test_str1 = L"가나다라마"; | |
wchar_t *test_str2 = L"abcde"; | |
printf("%d\n", is_contain_hangul(test_str1)); | |
printf("%d\n", is_contain_hangul(test_str2)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment