zoukankan      html  css  js  c++  java
  • 利用ICE编写程序的几个注意点

    利用ICE写程序时,一定要注意的几件事

    1、用Windows作为服务器是一件非常不爽的事。

    2、在windows下写客户端的时候,一定要用slice2xxx.exe的版本,否则在vc中可能编译过去,会有一些奇怪的问题,可能是vc中的stl与stl_port还会有一定的本质区别。

    3、涉及到汉字的时候,一定要记得将utf8码转换成gbk码,要不 一定是乱码

    附转码程序:

    // stdafx.h : include file for standard system include files,
    //  or project specific include files that are used frequently, but
    //      are changed infrequently
    //

    #if !defined(AFX_STDAFX_H__2843B98C_6C05_4A40_9CBC_51BD61B69760__INCLUDED_)
    #define AFX_STDAFX_H__2843B98C_6C05_4A40_9CBC_51BD61B69760__INCLUDED_

    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000

    #define VC_EXTRALEAN  // Exclude rarely-used stuff from Windows headers
    #undef _WINDOWS_
    #include <afxwin.h>         // MFC core and standard components
    #include <afxext.h>         // MFC extensions
    #include <afxdtctl.h>  // MFC support for Internet Explorer 4 Common Controls
    #ifndef _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h>   // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT

    //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.

    #endif // !defined(AFX_STDAFX_H__2843B98C_6C05_4A40_9CBC_51BD61B69760__INCLUDED_)

    #include "StdAfx.h"
    void ConvertGBKToUtf8(CString& strGBK);
    void ConvertUtf8ToGBK(CString& strUtf8);

    #include "UTF8.h"
    void ConvertGBKToUtf8(CString& strGBK) {
        int len=MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)strGBK, -1, NULL,0);
        unsigned short * wszUtf8 = new unsigned short[len+1];
        memset(wszUtf8, 0, len * 2 + 2);
        MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)strGBK, -1, wszUtf8, len);

        len = WideCharToMultiByte(CP_UTF8, 0, wszUtf8, -1, NULL, 0, NULL, NULL);
        char *szUtf8=new char[len + 1];
        memset(szUtf8, 0, len + 1);
        WideCharToMultiByte (CP_UTF8, 0, wszUtf8, -1, szUtf8, len, NULL,NULL);

        strGBK = szUtf8;
        delete[] szUtf8;
        delete[] wszUtf8;
    }

    void ConvertUtf8ToGBK(CString& strUtf8) {
        int len=MultiByteToWideChar(CP_UTF8, 0, (LPCTSTR)strUtf8, -1, NULL,0);
        unsigned short * wszGBK = new unsigned short[len+1];
        memset(wszGBK, 0, len * 2 + 2);
        MultiByteToWideChar(CP_UTF8, 0, (LPCTSTR)strUtf8, -1, wszGBK, len);

        len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
        char *szGBK=new char[len + 1];
        memset(szGBK, 0, len + 1);
        WideCharToMultiByte (CP_ACP, 0, wszGBK, -1, szGBK, len, NULL,NULL);

        strUtf8 = szGBK;
        delete[] szGBK;
        delete[] wszGBK;
    }

  • 相关阅读:
    uni-app在小程序开发者工具:TypeError: Cannot read property ‘forceUpdate‘ of undefined
    windows部署多个tomcat并添加到服务开机自动启动
    区域填充算法和多边形填充的扫描线算法[转]
    如何在不规则多边形内均匀撒点的算法[转]
    基于Living Atlas数据为木里山体滑坡敏感性建模【转】
    重磅!前端开发技术之Vue架构知识分享[转]
    如何使用 IAM 策略授予对特定 AWS S3 文件夹的用户特定访问权限?
    XXL-JOB安装、配置、启动、停止教程
    centos7 部署YApi
    CentOS 7安装MySQL8.0
  • 原文地址:https://www.cnblogs.com/adylee/p/1324842.html
Copyright © 2011-2022 走看看