//.h
/** * @brief char convertion * @file NAStingUNIT.h * @author welbon * @Email < libo.weng@gmail.com > * * Copyright (C) 1996-2010 SINA Corporation, All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #pragma once #include <stdio.h> #include <tchar.h> #include <string> /** 字符串轉化類 * * @author loach * * @date 2008-07-09 */ class CNAStringUNIT { public: /** Convert utf8 to microsoft unicode */ std::wstring NA_Utf8ToUnicode(const char *zFilename); /* ** Convert microsoft unicode to UTF-8. Space to hold the returned string is ** obtained from malloc(). */ std::string NA_UnicodeToUtf8(const wchar_t *zWideFilename); /* ** Convert an ansi string to microsoft unicode, based on the ** current codepage settings for file apis. ** ** Space to hold the returned string is obtained ** from malloc. */ std::wstring NA_MbcsToUnicode(const char *zFilename); /* ** Convert microsoft unicode to multibyte character string, based on the ** user's Ansi codepage. ** ** Space to hold the returned string is obtained from ** malloc(). */ std::string NA_UnicodeToMbcs(const wchar_t *zWideFilename); /* ** Convert multibyte character string to UTF-8. Space to hold the ** returned string is obtained from malloc(). */ std::string NA_MbcsToUtf8(const char *zFilename); /* ** Convert UTF-8 to multibyte character string. Space to hold the ** returned string is obtained from malloc(). */ std::string NA_Utf8ToMbcs(const char *zFilename); /** 是否是郵箱地址 */ bool NA_isemail(const char *str); /** 是否是字符串*/ bool NA_isalpha(const char *str); /** 是否是數字 */ bool NA_isalnum(const char* str); /** 是否是0-9數字 */ bool NA_isdigit(const char *str); };
//.cpp
/** * @brief char convertion * @file NAStingUNIT.cpp * @author welbon * @Email < libo.weng@gmail.com > * * Copyright (C) 1996-2010 SINA Corporation, All Rights Reserved * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ #include "Stdafx.h" #include "NAStringUNIT.h" #include <malloc.h> #include <windows.h> std::wstring CNAStringUNIT::NA_Utf8ToUnicode(const char *zFilename) { int nChar; wchar_t *zWideFilename; nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); int nSize = nChar*sizeof(zWideFilename[0]); zWideFilename = new wchar_t[nSize+1]; if( zWideFilename==0 ){ return 0; } nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nSize); if( nChar==0 ){ delete zWideFilename; zWideFilename = 0; } else zWideFilename[nChar] = 0; std::wstring strFileName = zWideFilename; delete []zWideFilename; return strFileName; } /* ** Convert microsoft unicode to UTF-8. Space to hold the returned string is ** obtained from sqliteMalloc(). */ std::string CNAStringUNIT::NA_UnicodeToUtf8(const wchar_t *zWideFilename) { int nByte; char *zFilename; nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, 0, 0, 0, 0); zFilename = new char[nByte +1]; if( zFilename==0 ){ return 0; } nByte = WideCharToMultiByte(CP_UTF8, 0, zWideFilename, -1, zFilename, nByte+1, 0, 0); if( nByte == 0 ){ delete zFilename; zFilename = 0; } else zFilename[nByte]='/0'; std::string strFileName = zFilename; delete []zFilename; return strFileName; } /* ** Convert an ansi string to microsoft unicode, based on the ** current codepage settings for file apis. ** ** Space to hold the returned string is obtained ** from sqliteMalloc. */ std::wstring CNAStringUNIT::NA_MbcsToUnicode(const char *zFilename) { int nByte; wchar_t *zMbcsFilename; int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, NULL,0);//*sizeof(wchar_t); int nSize = nByte*sizeof(zMbcsFilename[0]); zMbcsFilename = new wchar_t[nSize+1]; if( zMbcsFilename==0 ){ return 0; } nByte = MultiByteToWideChar(codepage, 0, zFilename, -1, zMbcsFilename, nSize); if( nByte==0 ){ delete zMbcsFilename; zMbcsFilename = 0; } else zMbcsFilename[nByte]=0; std::wstring strFileName = zMbcsFilename; delete []zMbcsFilename; return strFileName; } /* ** Convert microsoft unicode to multibyte character string, based on the ** user's Ansi codepage. ** ** Space to hold the returned string is obtained from ** sqliteMalloc(). */ std::string CNAStringUNIT::NA_UnicodeToMbcs(const wchar_t *zWideFilename) { int nByte; char *zFilename; int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, 0, 0, 0, 0); zFilename = new char[ nByte+1]; if( zFilename==0 ){ return 0; } nByte = WideCharToMultiByte(codepage, 0, zWideFilename, -1, zFilename, nByte+1, 0, 0); if( nByte == 0 ){ delete zFilename; zFilename = 0; } else zFilename[nByte]='/0'; std::string strFileName = zFilename; delete []zFilename; return strFileName; } /* ** Convert multibyte character string to UTF-8. Space to hold the ** returned string is obtained from sqliteMalloc(). */ std::string CNAStringUNIT::NA_MbcsToUtf8(const char *zFilename) { // char *zFilenameUtf8; std::wstring zTmpWide = NA_MbcsToUnicode(zFilename); if( zTmpWide.empty() ){ return std::string(""); } return NA_UnicodeToUtf8(zTmpWide.c_str()); } /* ** Convert UTF-8 to multibyte character string. Space to hold the ** returned string is obtained from sqliteMalloc(). */ std::string CNAStringUNIT::NA_Utf8ToMbcs(const char *zFilename) { std::wstring zTmpWide = NA_Utf8ToUnicode(zFilename); if( zTmpWide.empty() ){ return std::string(""); } return NA_UnicodeToMbcs(zTmpWide.c_str()); } /** 是否是郵箱地址 */ bool CNAStringUNIT::NA_isemail(const char *str) { if(!str) return false; const char *tmpstr = strchr(str, '@'); if(!tmpstr || tmpstr==str) return false; const char *t = str; while(t!=tmpstr) { if(!isalnum(*t) && *t!='-' && *t!='_' && *t!='.') break; t++; } if(t!=tmpstr) return false; t++; while(*t) { if(!isalnum(*t) && *t!='-' && *t!='.') { return false; } t++; } return true; } bool CNAStringUNIT::NA_isalpha(const char *str) { if(!str) return false; while(isalpha(*str))str++; return *str=='/0'; } bool CNAStringUNIT::NA_isalnum(const char* str) { if(!str) return false; while(isalnum(*str))str++; return *str=='/0'; } bool CNAStringUNIT::NA_isdigit(const char *str) { if(!str) return false; while(isdigit(*str))str++; return *str=='/0'; }
一、說明 在平常工作中,我們使用top命令查看一臺linux服務器的cpu使用情況時,會發現某個進程的cpu使用率會超過100%,這是爲什麼? 二、舉例 實驗環境爲 CentOS7.6 + Python2.7 1. 多線程、多進程在操作系統
一、概述 安裝某些數據庫的時候使用圖像化還是比較方便的,但是由於服務器一般不提供圖形化界面。之前一直都是使用Xmanager去導出圖形,但是Xmanager是收費的,公司不讓用,所以找了一款可以完美替代的產品Xming,本文將介紹xming
一、說明 同事問我數據庫的時區是客戶端屬性還是服務端屬性,我覺得這個問題十分有意思,之前沒怎麼留意,自己來做下實驗。 首先介紹幾個術語。 GMT(Greenwich Mean Time),格林尼治平均時間。 UTC(Coordinated
一. 找出表test1中tflag字段連續出現3次及以上爲1的行 思路:1. 對行進行編號,2. 對相鄰三行進行求和算出值作爲sumflag,3. 如果值爲3,則該行以及接下來的2行都輸出出來,通過自關聯解決。 WITH tmp AS (
數據結構 數據庫的表和索引缺一不可 表 特點: 無序,插入速度快,查找速度慢 索引(B+Tree) 特點:有序,插入速度慢,查找速度快 查找的效率比較,如果按照讀取的數據塊來計算? 測試數據 TABLE_OWNER TABLE
介紹:我有兩臺數據庫,分別稱爲200和203,200和203的服務器性能配置相當,203的配置甚至還要好一點。都是安裝的centos7.7,oracle 19C,均已開日誌歸檔,這兩臺服務器在同一個機房,同一個網段。當我在本地使用JDBC去
1.使用系統的root賬戶 2.切換到 /use/local 目錄下 3.下載mysql 根據自己需要安裝的版本下載。 wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysq
本篇參考: https://help.salesforce.com/s/articleView?id=release-notes.rn_lab_conditional_visibiliy_tab.htm&release=250&type=
示例demo: DECLARE @table IdTableType INSERT INTO @table SELECT Id FROM dbo.t_pl_test DECLARE @SearchSQL NVARCHAR(MAX) SE
在大數據計算裏面,計算引擎是處於承上啓下的作用,對上承接數據源,對下承接各種各種數據庫,比如mysql、oracle。對於任何數據計算來說要想精確消費一次,就需要支持事務或者冪等,我們最常見的支持事務的就是單點的oracle、mysql數
LiveCharts2 LiveCharts2是一個.NET開源(MIT License)、簡單、靈活、交互式且功能強大的.NET圖表、地圖和儀表,現在幾乎可以在任何地方運行如:Maui、Uno Platform、Blazor-wasm、W
前言 在之前的 面試官:來說說vue3是怎麼處理內置的v-for、v-model等指令? 文章中講了transform階段處理完v-for、v-model等指令後,會生成一棵javascript AST抽象語法樹。這篇文章我們來接着講gen
標題一 標題二 標題三 標題四 標題五 標題六 hr 加粗字體 b 斜體字體 i 引用內容 code 超鏈接 a blockquote ol > li 有序列表 ul > li 無須列表 pre 代碼塊 p 表格標
ue生成VS工程報錯 右鍵 - uproject ,Generating VisualStudio project files ,報錯信息如下:就是我安裝的msvc版本太舊 Running C:/Program Files/Epic Ga
因網絡中斷或其他原因,有時候服務器上留下較多無用的vscode-server進程,佔用內存資源 可以採用如下命令kill進程 ps uxa | grep .vscode-server | awk '{print $2}' | xargs k