ICE专题:利用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;
}




本文转自斯克迪亚博客园博客,原文链接:http://www.cnblogs.com/sgsoft/archive/2007/05/02/734482.html,如需转载请自行联系原作者

相关文章
|
11月前
|
存储 弹性计算 编解码
阿里云CPU服务器c7、g7和r7处理器Intel Xeon(Ice Lake) Platinum 8369B
阿里云第七代云服务器ECS计算型c7、通用型g7和内存型r7实例,CPU处理器采用2.7 GHz主频的Intel Xeon(Ice Lake) Platinum 8369B,全核睿频3.5 GHz,计算性能稳定。c7、g7和r7区别CPU内存比,阿里云服务器网来详细说下阿里云第七代云服务器c7、g7和r7实例CPU性能评测:
218 0
|
11月前
|
存储 弹性计算 编解码
阿里云ECS服务器g7、c7和r7处理器CPU采用Intel Xeon(Ice Lake) Platinum 8369B
阿里云第七代云服务器ECS计算型c7、通用型g7和内存型r7实例,CPU处理器采用2.7 GHz主频的Intel Xeon(Ice Lake) Platinum 8369B,全核睿频3.5 GHz,计算性能稳定。c7、g7和r7区别CPU内存比,阿里云服务器网来详细说下阿里云第七代云服务器c7、g7和r7实例CPU性能评测:
201 0
|
11月前
|
存储 弹性计算 安全
阿里云CPU处理器Intel Xeon(Ice Lake) Platinum 8369B
阿里云服务器CPU处理器Intel Xeon(Ice Lake) Platinum 8369B,基频2.7 GHz,全核睿频3.5 GHz,计算性能稳定。目前阿里云第七代云服务器ECS计算型c7、ECS通用型g7、内存型r7等规格均采用该款CPU
231 0
|
11月前
|
存储 弹性计算 安全
Intel Xeon(Ice Lake) Platinum 8369B
阿里云服务器CPU处理器Intel Xeon(Ice Lake) Platinum 8369B,基频2.7 GHz,全核睿频3.5 GHz,计算性能稳定。目前阿里云第七代云服务器ECS计算型c7、ECS通用型g7、内存型r7等规格均采用该款CPU
447 0
Intel Xeon(Ice Lake) Platinum 8369B
|
12月前
|
存储 弹性计算 安全
阿里云服务器CPU处理器Intel Xeon(Ice Lake) Platinum 8369B
阿里云服务器CPU处理器Intel Xeon(Ice Lake) Platinum 8369B,基频2.7 GHz,全核睿频3.5 GHz,计算性能稳定。目前阿里云第七代云服务器ECS计算型c7、ECS通用型g7、内存型r7等规格均采用该款CPU
|
自然语言处理 Java C++
|
存储 C# 数据库
|
中间件 ice 开发框架