Android 中文文件名、带空格文件名读取或者播放问题

假设文件名存在字符串对象myFile中。

那么,可通过myFile = Uri.encode(myFile);的方式,解决文件名中带空格、文件名中有中文字符时无法读取或者播放的问题。
http://blog.csdn.net/aminfo/article/details/7820470

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
里面包含两个文件. 一个是.h的头文件,一个是c的源程序 使用前需要先执行 gcc -c cJSON.c 生成cJSON.o文件 然后在你的程序中进行包含 #include "cJSON.h" 编译时 需要跟随参数 gcc空格-o空格[要生成的文件名]空格[你的源文件.c]空格cJSON.o空格`mysql_config空格--cflags空格--libs`空格-D_GNU_SOURCE空格-D__USE_XOPEN 例如: gcc -o test test.c cJSON.o `mysql_config --cflags --libs` -D_GNU_SOURCE -D__USE_XOPEN 笔者用的gcc是架构在centos 系统上的, 至于其他系统是否也有同样的要求就不是很确认了 另外 附赠 操作cJSON 可能需要前置包 一下是我用到的 #include <errno.h> #include <stdio.h> #include <time.h> #include <stdlib.h> #include <string.h> #include <arpa/inet.h> #include <sys/socket.h> #include <mysql/mysql.h> #include <unistd.h> #include <sys/shm.h> #include "cJSON.h" 下面是操作实例 数组转换为JSON cJSON *YearMonthJson = cJSON_CreateObject(); cJSON_AddStringToObject(YearMonthJson,"UpReferKey", Belong2Partner.UpReferKey ); cJSON_AddNumberToObject(YearMonthJson,"All", Belong2Partner.All ); cJSON *EachDayJson = cJSON_CreateArray(); cJSON_AddItemToObject(YearMonthJson,"EachDay",EachDayJson); for(int i=0;i<31;i++){ cJSON *EachDayJsonChild = cJSON_CreateArray(); cJSON_AddItemToArray(EachDayJson,EachDayJsonChild); for(int j=0;j<4; j++){ cJSON_AddItemToArray(EachDayJsonChild, cJSON_CreateNumber(Belong2PartnerEachDay[j])); } } 输出 printf("【%d】ChangeLogJson = '%s'\n",__LINE__,cJSON_PrintUnformatted(YearMonthJson)); 下面是json转换为数组 cJSON *YearMonthJson = cJSON_CreateObject(); YearMonthJson = cJSON_Parse(PartnerRow); if(cJSON_GetObjectItem(YearMonthJson,"All")) Belong2Partner->All = cJSON_GetObjectItem(YearMonthJson,"All")->valuelong; else Belong2Partner->All =0; cJSON *EachDayJson=cJSON_CreateArray(); if(cJSON_GetObjectItem(YearMonthJson,"EachDay")){ EachDayJson= cJSON_GetObjectItem(YearMonthJson,"EachDay"); } for(int i=0;i<31;i++){ cJSON *EachDayJsonChild = cJSON_CreateObject(); if(cJSON_GetArrayItem(EachDayJson,i)){ 数组[i]=cJSON_GetArrayItem(EachDayJson,i); } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值