ustring.cpp
来自「一个简单的学籍管理系统我也是从别人那考看过来的」· C++ 代码 · 共 41 行
CPP
41 行
///////////////////////////////////////////////////////////////////////////////
//
// ustring.cpp - Copyright 1997, Don Box
//
// This file contains the implementation of several conversion routines
// that are used by the String816 class for duplicating/converting strings
// on the fly.
//
// uxdup(const char *psz) - returns a new-ed wchar_t string based on psz
// uxdup(const wchar_t *psz) - returns a new-ed char string based on psz
//
#include <stdafx.h>
#ifndef _USTRING_CPP
#define _USTRING_CPP
wchar_t *uxdup(const char *psz)
{
size_t cch = strlen(psz) + 1;
wchar_t *pwszResult = (wchar_t*)malloc(cch * sizeof(wchar_t));
if (pwszResult)
mbstowcs(pwszResult, psz, cch);
return pwszResult;
}
char *uxdup(const wchar_t *pwsz)
{
size_t cch = wcslen(pwsz) + 1;
char *pszResult = (char*)malloc(sizeof(char) * cch);
if (pszResult)
wcstombs(pszResult, pwsz, cch);
return pszResult;
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?