首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android NDK和__android_log_print

Android NDK和__android_log_print
EN

Stack Overflow用户
提问于 2012-02-21 22:35:08
回答 2查看 5.1K关注 0票数 2

我使用JNI中的lib:https://github.com/mysolution/hyphenator创建这个函数:

代码语言:javascript
复制
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):�

如何解决这个问题?我认为编码中存在这个问题,但我不知道如何解决这个问题。

EN

回答 2

Stack Overflow用户

发布于 2012-02-22 02:13:59

您的预期输出是多少?如果字符不属于ASCII域,那么您当然需要有一些东西来查看支持它的logcat。假设您输出的是UTF-8,那么在Linux和Mintty上(与Cygwin/等结合使用) Terminator是很好的。在Windows上。

票数 0
EN

Stack Overflow用户

发布于 2012-05-21 16:44:00

我解决了这个问题,这在我看来是非常错误的……

因此,对于__android_log_vprint和__android_log_print中的字符*连接,您似乎需要使用转义%s,而不是%c。

这完全打乱了我在iOS、安卓和黑莓之间创建跨平台char* log的计划,因为printf("%s",myString.c_str());是非法的。将不得不使用args并解析字符串。无论如何,这是另一个问题,这是你的解决办法……

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9379365

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档