//.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'; }
流程 Master數據庫安裝 Slave數據庫安裝 配置Master數據庫 配置Slave數據庫 網絡信息 Master數據庫IP:192.168.198.133 Slave數據庫IP:192.168.198.132 配置Maste
題目是輸入一串字符串,包含空格,裏面有多個單詞,將每個單詞翻轉輸出,並且單詞之間的空格要與原文一致。 寫的時候沒有使用string的輸入,而是選擇了char數組的輸入。 樣例測試hello world->olleh dlrow是沒有問題的,
對數據量過億的大表而言,dba最頭疼的是隨着業務變化增加帶默認值的字段,以及修改字段的數據類型,在實現不好的數據庫中,動不動執行半天,中途失敗的話,還會卡半天。這在lightdb中是不會發生的。如下所示: lightdb@oradb=
數據庫設計通常需要滿足一定的範式要求,其中主鍵更是最基本的要求。不過,數據庫管理系統卻允許我們創建沒有主鍵的表。這樣的表在數據庫中會帶來查詢性能低下、複製延遲甚至無法實現高可用配置等問題。 爲此,lightdb在22.1版本引入了一
在業務開發中,通常因爲代碼不規範、中間件缺陷、DBA誤提交批量SQL等原因,會導致服務端連接一直存在、但是實際上並未在執行的情況,從而導致數據庫連接泄露。爲了防止這種異常情況積壓,lightdb中包含了多個參數用於控制超時相關的行爲:
有時候,我們需要在網頁判斷用戶是否處與非活躍狀態,如果用戶長時間沒有在頁面上進行任何操作,我們則判定該用戶是非活躍的。 在 javascript 中我們可以通過監聽某些鼠標或鍵盤相關的事件來判定用戶是否在活躍中。 案例演示 在線演示 - 使
在前端開發過程中,調試的時候,我門會使用 console.log 等方式查看數據。但對於圖片來說,僅靠展示的數據與結構,是無法想象出圖片最終呈現的樣子的。 雖然我們可以把圖片數據通過 img 標籤展示到頁面上,或將圖片下載下來進行預覽。但這
安裝負載均衡metalb 安裝metalb kubectl create namespace metallb-system 配置metalb #kubectl create secret generic -n metallb-system
有狀態的計算是流式計算框架的一個重要功能,很多複雜的計算場景都需要記錄一下相關的狀態。Flink State一種爲了滿足算子計算時需要歷史數據需求的,使用 checkpoint 機制進行容錯,存儲在 state backend 的數
前言 在日常開發中,我們常常需要將一個對象映射到另一個對象,這個過程中可能需要編寫大量的重複性代碼,如果每次都手動編寫,不僅會影響開發效率,而且當項目越來越複雜、龐大的時候還容易出現錯誤。爲了解決這個問題,對象映射庫就隨之而出了,這些庫可以
一. 二. 三. ! 作 者 : Yaopengfei(姚鵬飛) 博客地址 : http://www.cnblogs.com
在Winform使用RDLC時,在批量打印情況下,內存隨着打印任務的數量逐漸增加。即便手動GC效果也不明顯。 原因: localReport在創建時,每個實例都是一個應用程序域。租約的過期時間比較久,按照網上的資料,過期時間大約10分鐘左右
1、Solon Cloud Event? 是 Solon 分佈式事件總線的解決方案。也是 Solon “最終一致性”分佈式事務的解決方案之一 2、事務特性 事務?就是要求 Event 有原子性,當多個 Event 發佈時,要麼全成功,要麼
最近開始體驗FastGPT知識庫問答系統,參考官方文檔,在自己的阿里雲服務器使用Docker Compose快速完成了部署。 環境說明:阿里雲ECS,2核8G,X86架構,CentOS 7.9操作系統。 Docker與Docker-Com
之前有通過ode和simulink解線性常微分方程組。 除了上面兩種方法,線性常微分方程組還可以通過矩陣的方法求解。 比如下面這個之前使用的方程組: x'' = x' - x + y' -z' y'' = y' - y - x' z'' =