我使用这个lib: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):
如何解决这个问题?我认为编码有问题,但我不知道如何解决这个问题。
答案 0 :(得分:0)
您的预期产量是多少?如果角色超出了ASCII的范围,你当然需要有东西来查看支持它的logcat。假设您正在输出UTF-8,Terminator在Linux上很好用Mintty(与Cygwin /等结合使用)在Windows上。
答案 1 :(得分:0)
我解决了,这对我来说似乎非常错误.....
因此,对于__android_log_vprint和__android_log_print中的char *连接,您似乎需要使用escape%s而不是%c。
这完全消除了我在iOS,Android和Blackberry之间制作跨平台char *日志作为printf的计划("%s",myString.c_str());是非法的。必须使用args获得时髦并解析字符串。无论如何,这是另一个问题,并且有你的修复......