我使用这个库:https://github.com/mysolution/hyphenator在 JNI 中,我创建了这个函数:
int main2()
{
//load russian hyphenation patterns
struct pattern_list_t* plist = create_pattern_list();
size_t i = 0;
while (patterns[i])
{
struct pattern_t* p = create_pattern(patterns[i], isdigit_func, ismarker_func, char2digit_func);
add_patern(plist, p);
++i;
}
sort_pattern_list(plist);
//hyphenate test words
size_t word_index = 0;
while (test_words[word_index])
{
struct word_hyphenation_t* wh = hyphenate_word(test_words[word_index], plist, marker);
i = 0;
while (test_words[word_index][i])
{
__android_log_print(ANDROID_LOG_INFO, "HelloNDK!", "%c", test_words[word_index][i]);
++i;
}
destroy_word_hyphenation(wh);
++word_index;
}
//cleanup
destroy_pattern_list(plist);
return 0;
}
在 Android NDK 中这项工作有效,但我进入了 LogCat:
02-21 16:15:18.989: INFO/HelloNDK!(403):
如何解决这个问题?我认为编码有问题,但我不知道如何解决。
最佳答案
您的预期输出是什么?如果该字符超出 ASCII 范围,您当然需要查看支持它的 logcat。假设您要输出 UTF-8,Terminator在 Linux 和 Mintty 上很好(结合 Cygwin/等)在 Windows 上。
关于Android NDK 和 __android_log_print,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9379365/