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;
    }

  • 相关阅读:
    CSS样式更改_2D转换
    使用本地json-server服务,创建简单的本地api数据
    为何不推荐使用 Sass 作为 css 预处理器
    移动端适配
    html 元素垂直水平居中
    场内场外基金和开户避坑
    QJson
    Merry Christmas Mr. Lawrence
    github,源码,高仿 直播
    P1314 聪明的质监员
  • 原文地址:https://www.cnblogs.com/adylee/p/1324842.html
Copyright © 2011-2022 走看看