我使用JNI中的lib:https://github.com/mysolution/hyphenator创建这个函数:
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:信息/HelloNDK!(18.989):�
如何解决这个问题?我认为编码中存在这个问题,但我不知道如何解决这个问题。
发布于 2012-02-22 02:13:59
您的预期输出是多少?如果字符不属于ASCII域,那么您当然需要有一些东西来查看支持它的logcat。假设您输出的是UTF-8,那么在Linux和Mintty上(与Cygwin/等结合使用) Terminator是很好的。在Windows上。
发布于 2012-05-21 16:44:00
我解决了这个问题,这在我看来是非常错误的……
因此,对于__android_log_vprint和__android_log_print中的字符*连接,您似乎需要使用转义%s,而不是%c。
这完全打乱了我在iOS、安卓和黑莓之间创建跨平台char* log的计划,因为printf("%s",myString.c_str());是非法的。将不得不使用args并解析字符串。无论如何,这是另一个问题,这是你的解决办法……
https://stackoverflow.com/questions/9379365
复制相似问题