資源簡(jiǎn)介
中文姓名自動(dòng)轉(zhuǎn)化為拼音,實(shí)測(cè)有效,附上源碼以及dll。bin下面有NPinyin.dll

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Text;
namespace?NPinyin
{
????class?CommonMethod
????{
????????#region?截取字符長(zhǎng)度?static?string?CutString(string?str?int?len)
????????///?
????????///?截取字符長(zhǎng)度
????????///?
????????///?被截取的字符串
????????///?所截取的長(zhǎng)度
????????///?子字符串
????????public?static?string?CutString(string?str?int?len)
????????{
????????????if?(str?==?null?||?str.Length?==?0?||?len?<=?0)
????????????{
????????????????return?string.Empty;
????????????}
????????????int?l?=?str.Length;
????????????#region?計(jì)算長(zhǎng)度
????????????int?clen?=?0;
????????????while?(clen?????????????{
????????????????//每遇到一個(gè)中文,則將目標(biāo)長(zhǎng)度減一。
????????????????if?((int)str[clen]?>?128)?{?len--;?}
????????????????clen++;
????????????}
????????????#endregion
????????????if?(clen?????????????{
????????????????return?str.Substring(0?clen)?+?“...“;
????????????}
????????????else
????????????{
????????????????return?str;
????????????}
????????}
????????///?
????????///?//截取字符串中文?字母
????????///?
????????///?源字符串
????????///?截取長(zhǎng)度!
????????///?
????????public?static?string?SubTrueString(object?content?int?length)
????????{
????????????string?strContent?=?content.ToString();//NoHTML(content.ToString());
????????????bool?isConvert?=?false;
????????????int?splitLength?=?0;
????????????int?currLength?=?0;
????????????int?code?=?0;
????????????int?chfrom?=?Convert.ToInt32(“4e00“?16);????//范圍(0x4e00~0x9fff)轉(zhuǎn)換成int(chfrom~chend)
????????????int?chend?=?Convert.ToInt32(“9fff“?16);
????????????for?(int?i?=?0;?i?????????????{
????????????????code?=?Char.ConvertToUtf32(strContent?i);
????????????????if?(code?>=?chfrom?&&?code?<=?chend)
????????????????{
????????????????????currLength?+=?2;?//中文
????????????????}
????????????????else
????????????????{
????????????????????currLength?+=?1;//非中文
????????????????}
????????????????splitLength?=?i?+?1;
????????????????if?(currLength?>=?length)
????????????????{
????????????????????isConvert?=?true;
????????????????????break;
????????????????}
????????????}
????????????if?(isConvert)
????????????{
????????????????return?strContent.Substring(0?splitLength);
????????????}
????????????else
????????????{
????????????????return?strContent;
????????????}
????????}
????????public?static?int?GetStringLenth(object?content)
????????{
????????????string?strContent?=?content.ToString();//?NoHTML(content.ToString());
????????????int?currLength?=?0;
????????????int?code?=?0;
????????????int?chfrom?=?Convert.ToInt32(“4e00“?16);????//范圍(0x4e00~0x9fff)轉(zhuǎn)換成int(chfrom~chend)
????????????int?chend?=?Convert.ToInt32(“9fff“?16);
????????????for?(int?i?=?0;?i?????????????{
????????????????code?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
????..A..H.?????49664??2017-08-16?16:29??NPinyin\.vs\NPinyin\v14\.suo
?????文件??????78848??2017-08-16?16:06??NPinyin\bin\Debug\NPinyin.dll
?????文件??????24064??2017-08-16?16:06??NPinyin\bin\Debug\NPinyin.pdb
?????文件???????3570??2017-08-16?16:00??NPinyin\CommonMethod.cs
?????文件???????3969??2017-08-16?16:03??NPinyin\NPinyin.csproj
?????文件???????2546??2012-07-16?21:37??NPinyin\NPinyin.sln
?????文件??????26112??2012-07-24?11:13??NPinyin\NPinyin.suo
?????文件??????78848??2017-08-16?16:06??NPinyin\NPinyinTest\bin\Debug\NPinyin.dll
?????文件??????24064??2017-08-16?16:06??NPinyin\NPinyinTest\bin\Debug\NPinyin.pdb
?????文件???????6144??2017-08-16?16:08??NPinyin\NPinyinTest\bin\Debug\NPinyinTest.exe
?????文件??????11776??2017-08-16?16:08??NPinyin\NPinyinTest\bin\Debug\NPinyinTest.pdb
?????文件??????21688??2017-08-16?16:09??NPinyin\NPinyinTest\bin\Debug\NPinyinTest.vshost.exe
?????文件????????490??2017-03-19?05:00??NPinyin\NPinyinTest\bin\Debug\NPinyinTest.vshost.exe.manifest
?????文件???????2392??2012-07-16?21:37??NPinyin\NPinyinTest\NPinyinTest.csproj
?????文件???????5883??2017-08-16?15:52??NPinyin\NPinyinTest\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????597??2017-08-16?16:09??NPinyin\NPinyinTest\obj\x86\Debug\NPinyinTest.csproj.FileListAbsolute.txt
?????文件???????3918??2017-08-16?16:06??NPinyin\NPinyinTest\obj\x86\Debug\NPinyinTest.csprojResolveAssemblyReference.cache
?????文件???????6144??2017-08-16?16:08??NPinyin\NPinyinTest\obj\x86\Debug\NPinyinTest.exe
?????文件??????11776??2017-08-16?16:08??NPinyin\NPinyinTest\obj\x86\Debug\NPinyinTest.pdb
?????文件???????2263??2017-08-16?16:08??NPinyin\NPinyinTest\Program.cs
?????文件???????1372??2012-07-23?23:27??NPinyin\NPinyinTest\Properties\AssemblyInfo.cs
?????文件???????5788??2017-08-16?15:58??NPinyin\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????353??2017-08-16?15:52??NPinyin\obj\Debug\NPinyin.csproj.FileListAbsolute.txt
?????文件????????995??2017-08-16?15:52??NPinyin\obj\Debug\NPinyin.csprojResolveAssemblyReference.cache
?????文件??????78848??2017-08-16?16:06??NPinyin\obj\Debug\NPinyin.dll
?????文件??????24064??2017-08-16?16:06??NPinyin\obj\Debug\NPinyin.pdb
?????文件???????7051??2012-07-24?11:17??NPinyin\Pinyin.cs
?????文件???????1343??2012-07-24?11:11??NPinyin\Properties\AssemblyInfo.cs
?????文件??????25253??2012-07-16?21:37??NPinyin\PyCode.cs
?????文件??????36704??2012-07-16?21:37??NPinyin\PyHash.cs
............此處省略24個(gè)文件信息
評(píng)論
共有 條評(píng)論