Android的字符编码转换问题,Unicode,GB2312,UTF8等
来源:互联网 发布:胸卡 名片制作软件 编辑:程序博客网 时间:2024/05/22 18:56
/* jernymy 2011-12-01 * Android word encoder process, need libicuuc.so Api * just a example**//*--------------------------- tst.cpp ---------------------------*//* use dl API include file */#include <dlfcn.h>/* typedef a function pointer to pointer ucnv_convert method */#ifndef LPCSTRtypedef const char* LPCSTR;#endif#ifndef LPSTRtypedef char* LPSTR;#endif#ifndef s32typedef unsigned long s32;#endiftypedef void (*pvUcnvFunc)(LPCSTR lpcstrDstEcd, LPCSTR lpcstrSrcEcd, LPSTR lpstrOut, s32 nOutLen, LPCSTR lpstrIn, s32 nInLen, s32 *pnErrCode);/* ucnv_convert method pointer */static pvUcnvFunc g_pvUcnvConvert = NULL;/* pointer libicuuc.so dl lib */static void* g_pvUcnvDll = NULL;/*see the source code defineint32_t ucnv_convert( const char *toConverterName,const char *fromConverterName,char *target,int32_t targetSize,const char *source,int32_t sourceSize,UErrorCode * err)*/void UcnvConvert(LPSTR lpstrOut, s32 nOutLen, LPCSTR lpstrIn, s32 *pnErrC){/* load so for word convert */if (NULL == g_pvUcnvDll){g_pvUcnvDll = dlopen("/system/lib/libicuuc.so", RTLD_LAZY); }if (NULL == g_pvUcnvDll){LOGE("(NULL == g_pvUcnvDll)");return;}/* get convert Api pointer */if (NULL == g_pvUcnvConvert){/* here is Android 2.2 version, Android 2.1 version change to ucnv_convert_3_8 */g_pvUcnvConvert = (pvUcnvFunc)dlsym(g_pvUcnvDll, "ucnv_convert_4_2");}if (NULL == g_pvUcnvConvert){LOGE("(NULL == g_pvUcnvConvert)");return;} /* * utf8 --> the Destination encoder * gb2312 --> the Source encoder **/ g_pvUcnvConvert("utf8", "gb2312", lpstrOut, nOutLen, lpstrIn, strlen(lpstrIn), pnErrC); }/*--------------------------- tst.cpp ---------------------------*//*--------------------------- Android.mk ---------------------------*/# android for nc makefileLOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)# current path, local path jni/COMN_PATH := $(LOCAL_PATH)/../../../10-commonLOCAL_CFLAGS += -D_LINUX_ -g -fno-rtti -fno-short-enums -D_ANDROID_LOCAL_CPP_EXTENSION := .cppLOCAL_C_INCLUDES := \LOCAL_LDLIBS :=-L$(SYSROOT)/usr/lib -llog -ldlLOCAL_MODULE := tstLOCAL_SRC_FILES := tst.cppinclude $(BUILD_SHARED_LIBRARY)/*--------------------------- Android.mk ---------------------------*/
- Android的字符编码转换问题,Unicode,GB2312,UTF8等
- Android的字符编码转换问题,Unicode,GB2312,UTF8等
- 大端小端,ascii,unicode,utf8,utf16,utf32,gb2312,gbk,gb18030等字符编码问题
- 大端小端,ascii,unicode,utf8,utf16,utf32,gb2312,gbk,gb18030等字符编码问题
- 大端小端,ascii,unicode,utf8,utf16,utf32,gb2312,gbk,gb18030等字符编码问题
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的?
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的?
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的?(...
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的?
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的?
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的
- 字符编码知识:Unicode、UTF-8、ASCII、GB2312等编码之间是如何转换的?[转]
- utf8, unicode, gb2312 编码转换vc++
- 字符编码转换(utf8-unicode)
- c#实现GB2312和UTF8字符编码方式的转换!
- UTF8 编码方式,以及GB2312、Unicode、UCS等编码介绍。
- 字符编码的问题ASCII UTF8 GBK GB2312
- 杂七杂八的安卓程序!
- Nutch 1.3 源码分析 8 LinkDb
- struts2 Validator 整合freemarker 取得FieldError的方法
- Android Notification介绍
- 通过XMLReader 读取服务器的xml 文件(通过sax2)
- Android的字符编码转换问题,Unicode,GB2312,UTF8等
- 编译生成CLASS文件
- java.lang.ExceptionInInitializerError异常的的解决方法
- Linux 启动时 nfs服务启动慢的问题的解决
- Windows 下Android 开发环境搭建
- android系统信息(内存、cpu、sd卡、电量、版本)获取
- hdoj 2063 (二分图匹配)
- C/C++/C#面试题精选(2)
- 发几个优秀的SEO博客