Ice topic: notes on using ice to write programs

Source: Internet
Author: User

 

ExploitationIceSeveral things you must pay attention to when writing a program

1. Using Windows as a server is a very unpleasant thing.

2. When writing the client terminal in Windows, you must use the slice2xxx.exe version. Otherwise, it may be difficult to compile it in VC. It may be because STL and stl_port in VC may have some essential differences.

3. When it comes to Chinese characters, remember to convert the utf8 code into a GBK code. Otherwise, it must be garbled.

Attached transcoding program:

// Stdafx. h: Include File for standard system include files,
// Or project specific include files that are used frequently,
// Are changed infrequently
//

# If! Defined (afx_stdafx_h00002843b98c_6c05_4a40_9cbc_51bd61b697601_included _)
# Define afx_stdafx_h1_2843b98c_6c05_4a40_9cbc_51bd61b697601_encoded _

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.