cocos2d-x节点(ccUTF8.h)API
2013-11-30 14:16
176 查看
本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
UTF-16 转换为 UTF-8,统计写入/读取的字节数
cocos2d-x节点(ccUTF8.h)API
温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记UTF-16 转换为 UTF-8,统计写入/读取的字节数
///cocos2d-x-3.0alpha0/cocos2dx/support //UTF-16 转换为 UTF-8,统计 写入/读取 的字节数 // // ccUTF8.h // cocos2dx // // Created by James Chen on 2/27/13. // #ifndef __cocos2dx__ccUTF8__ #define __cocos2dx__ccUTF8__ #include "platform/CCPlatformMacros.h" #include <vector> NS_CC_BEGIN CC_DLL int cc_wcslen(const unsigned short* str); CC_DLL void cc_utf8_trim_ws(std::vector<unsigned short>* str); /** * 该字符是否是空白字符。 * * @param ch Unicode字符 * @returns 该字符是否是空白字符 * * @see http://en.wikipedia.org/wiki/Whitespace_character#Unicode * */ CC_DLL bool isspace_unicode(unsigned short ch); /** * Returns 字符中的字符串的长度。 * * @param p 指向一个UTF-8编码字符串的开始 * @param max 检查字节的最大数量。如果\ P max是小于0,则该字符串被假定为null结尾的。如果最大的\ p为0,\ PP不会被检查,我的是%NULL。 * * @returns the length of the string in characters **/ CC_DLL long cc_utf8_strlen (const char * p, int max); /** * 寻找不等于给定的字符的最后一个字符。 * * @param str the string to be searched. * @param c 要搜索的字符. * * @returns the index of the last character that is not \p c. //index最后一个字符不是 \p c * */ CC_DLL unsigned int cc_utf8_find_last_not_char(std::vector<unsigned short> str, unsigned short c); CC_DLL std::vector<unsigned short> cc_utf16_vec_from_utf16_str(const unsigned short* str); /** * Creates a utf8 string from a cstring. * * @param str_old pointer to the start of a C string. * * @returns the newly created utf8 string. * */ CC_DLL unsigned short* cc_utf8_to_utf16(const char* str_old, int length = -1, int* rUtf16Size = NULL); /** * Convert a string from UTF-16 to UTF-8. The result will be null terminated. * * @param str a UTF-16 encoded string * @param len the maximum length of \p str to use. If \p len < 0, then the * string is null terminated. * @param items_read 读取到的本地存储的单词数,如果%NULL,那么%G_CONVERT_ERROR_PARTIAL_INPUT 将返回一个包含 \p str 的结尾字符,如果发生一个错误,无效的输入 index 储存在这里 * @param items_written 写入到本地的 byte数,or %NULL. * 这里存储的值不包括结尾的 null. * * @returns 个新分配的UTF-8字符串指针。这个值必须是 *用free()释放。如果发生错误,%将返回NULL。 **/ CC_DLL char * cc_utf16_to_utf8 (const unsigned short *str, long len, long *items_read, long *items_written); NS_CC_END #endif /* defined(__cocos2dx__ccUTF8__) */
相关文章推荐
- cocos2d-X 节点(SpriteBatchNode.h.)API
- cocos2d-X 节点(CCTMXObjectGroup.h)API
- cocos2d-X 节点(CCActionObject.h)API
- cocos2d-X 节点(UIScrollView.h)API
- cocos2d-x节点(b2MouseJoint.h)API
- cocos2d-x节点(b2Collision.h)API
- cocos2d-x节点(ccGLStateCache.h)API
- cocos2d-x节点(CCPlatformConfig.h)API
- cocos2d-x节点(CCParticleBatchNode.h)API
- cocos2d-x节点(CCTransition.h)API
- cocos2d-x节点(CCEventListenerCustom.h)API
- cocos2d-x节点(ccConfig.h)API
- cocos2d-x节点(CCAffineTransform.h)API
- cocos2d-X 节点(CCSpriteFrame.h..)API
- cocos2d-X 节点(UIRootWidget.h)API
- cocos2d-X 节点(UIButton.h)API
- cocos2d-x节点(b2GearJoint.h)API
- cocos2d-x节点(b2BroadPhase.h)API
- cocos2d-x节点(CCGLProgram.h)API
- cocos2d-x节点(CCPlatformMacros.h)API