Check if there is Chinese in the string

xiaoxiao2021-03-06  42

[DllImport ( "KERNEL32.DLL", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] private static extern int WideCharToMultiByte (uint CodePage, uint dwFlags, string lpWideCharStr, int cchWideChar, string lpMultiByteStr , Int cchmultibyte, string lpdefaultchar, int lpuseddefaultchar);

Private const uint cp_acp = 0x0;

Public void iShaveChinese () {string m_str = "ABC Speech"; int Nlen = WideChartomultibyte (CP_ACP, 0, M_STR, M_STR.LENGTH, NULL, 0, NULL, 0); if (m_str.length! = nlen) {MessageBox .Show ("there is Chinese characters.");} Else {messagebox.show ("There is no Chinese characters.");}}

转载请注明原文地址:https://www.9cbs.com/read-113194.html

New Post(0)