当前位置: 首页 > news >正文

站长工具 seo查询医院seo是什么

站长工具 seo查询,医院seo是什么,网站制作优质公司,东莞做网站的网络公司在使用cocos2dx c开发项目时,通常使用cocos自带的UserDefault来存储一些项目所用到的一些配置信息:如游戏的音量,游戏的闯关数等... 但是windows平台下,测试发现如果用户的帐户名使用是中文,在启动程序时会报错&#…

在使用cocos2dx c++开发项目时,通常使用cocos自带的UserDefault来存储一些项目所用到的一些配置信息:如游戏的音量,游戏的闯关数等...

但是windows平台下,测试发现如果用户的帐户名使用是中文,在启动程序时会报错,导致程序无法运行。经过排查,把问题定位到CCFileUtils-win32.cpp的FileUtilsWin32::getWritablePath函数中:string FileUtilsWin32::getWritablePath() const
{
    // Get full path of executable, e.g. c:\Program Files (x86)\My Game Folder\MyGame.exe
    char full_path[CC_MAX_PATH + 1];
    ::GetModuleFileNameA(nullptr, full_path, CC_MAX_PATH + 1);
 
    // Debug app uses executable directory; Non-debug app uses local app data directory
//#ifndef _DEBUG
        // Get filename of executable only, e.g. MyGame.exe
        char *base_name = strrchr(full_path, '\\');
 
        if(base_name)
        {
            char app_data_path[CC_MAX_PATH + 1];
 
            // Get local app data directory, e.g. C:\Documents and Settings\username\Local Settings\Application Data
            if (SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, app_data_path)))
            {
                string ret((char*)app_data_path);
 
                // Adding executable filename, e.g. C:\Documents and Settings\username\Local Settings\Application Data\MyGame.exe
                ret += base_name;
 
                // Remove ".exe" extension, e.g. C:\Documents and Settings\username\Local Settings\Application Data\MyGame
                ret = ret.substr(0, ret.rfind("."));
 
                ret += "\\";
 
                // Create directory
                if (SUCCEEDED(SHCreateDirectoryExA(nullptr, ret.c_str(), nullptr)))
                {
                    return convertPathFormatToUnixStyle(ret);
                }
            }
        }
//#endif // not defined _DEBUG
 
    // If fetching of local app data directory fails, use the executable one
    string ret((char*)full_path);
 
    // remove xxx.exe
    ret =  ret.substr(0, ret.rfind("\\") + 1);
 
    ret = convertPathFormatToUnixStyle(ret);
 
    return ret;
}

这里可以看到作者在使用
SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, app_data_path))
这个函数时,目的是想通过
CSIDL_LOCAL_APPDATA
来把路径定位到帐户下的APPData目录,而CSIDL_LOCAL_APPDATA这个宏的解释是:

#define CSIDL_LOCAL_APPDATA             0x001c        // <user name>\Local Settings\Applicaiton Data (non roaming)

微软在解释SHGetFolderPath时,说明了用法:

SHGetFolderPathW (Unicode) and SHGetFolderPathA (ANSI)
由于ANSI的兼容性不好,很多情况会导致中文乱码,所以这里需要修改SHGetFolderPathW来将字符集转成unicode,这样比较好用。

修改过后:


string FileUtilsWin32::getWritablePath() const
{
    // Get full path of executable, e.g. c:\Program Files (x86)\My Game Folder\MyGame.exe
    char full_path[CC_MAX_PATH + 1];
    ::GetModuleFileNameA(nullptr, full_path, CC_MAX_PATH + 1);
 
    // Debug app uses executable directory; Non-debug app uses local app data directory
//#ifndef _DEBUG
    // Get filename of executable only, e.g. MyGame.exe
    char *base_name = strrchr(full_path, '\\');
 
    if(base_name)
    {
     // Get local app data directory, e.g. C:\Documents and Settings\username\Local Settings\Application Data
    WCHAR utf16Path[CC_MAX_PATH + 1] = { 0 };
    if(SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, utf16Path)))
    {
            char utf8_path[1024 + 2] = { 0 };
        WideCharToMultiByte(CP_UTF8, 0, utf16Path, CC_MAX_PATH + 1, utf8_path, 1024 + 2, NULL, NULL);
        string ret((char*)utf8_path);
        // Adding executable filename, e.g. C:\Documents and Settings\username\Local Settings\Application Data\MyGame.exe
        ret += base_name;
 
        // Remove ".exe" extension, e.g. C:\Documents and Settings\username\Local Settings\Application Data\MyGame
        ret = ret.substr(0, ret.rfind("."));
 
        ret += "\\";
 
        // Create directory
        if (SUCCEEDED(SHCreateDirectoryExA(nullptr, ret.c_str(), nullptr)))
        {
            return convertPathFormatToUnixStyle(ret);
        }
    }
     }
//#endif // not defined _DEBUG
 
    // If fetching of local app data directory fails, use the executable one
    string ret((char*)full_path);
 
    // remove xxx.exe
    ret =  ret.substr(0, ret.rfind("\\") + 1);
 
    ret = convertPathFormatToUnixStyle(ret);
 
    return ret;
}

这样就解决了中文目录下使用userDefault造成的程序崩溃问题。
 

http://www.yayakq.cn/news/967893/

相关文章:

  • 知名网站建设推广wordpress jitpecj插件
  • 简易购物网站前端模板1天学会搭建营销网站
  • 广州网站设计服务商免费创意字体设计
  • 大连中小网站建设公司做任务 网站
  • 局域网网站凡客科技有限公司
  • c语言网站建设南昌定制网站开发
  • 个人网站备案icp餐馆网站怎么做
  • 重庆市建设厅网站东营招标建设信息网
  • 怎样建设营销型网站课堂网站开发
  • 龙岩网站制作教程在线教育网站有什么程序做
  • 网站与云平台区别吗青岛的网站设计
  • 哈尔滨门户网站制作哪家好织梦与wordpress seo哪个好
  • 福建建设执业注册管理中心网站江西省城乡建设厅网站证件查询
  • 上海大型网站品牌网站建设 1蝌蚪小
  • dede修改网站密码在百度上做网站推广怎么弄
  • 长春网站推广优化深圳建设工程信息网站
  • 山东企业网站建设报价国家企业信息管理系统
  • 自己网站做短链接wordpress 主题详解
  • 如何判断一个网站是php还是asp自己的电脑做服务器搭建网站
  • 网站新闻详细页面设计网站建设的价值体现在哪
  • 福建省建设工程资格中心网站wordpress 按标题搜索
  • 网站建设作业教程收费网站方案
  • 哪里网站建设公司比较好如何查询关键词的搜索量
  • 怎么做网站写手网站建设考核指标
  • 什么是网站黏着度郴州365网
  • 丽江市住房建设局网站电子商务具体是干什么的
  • 北京公司网站建设推荐昆明网站建设公司排名
  • 纯html5 网站王烨辉
  • phpcms v9 实现网站搜索公司免费取名
  • 网站建设中的需求报告功能wordpress多域名绑定域名