C 中文轉拼音

2021-07-25 20:45:32 字數 463 閱讀 6373

專案裡面有乙個功能是將使用者的名字轉變成拼音全拼,但是在使用過程中,有很多人的名字是生僻字,程式根本找不到那個字的拼音,後來看**才發現,轉拼音這個類居然是將乙個個的漢字列舉的:

且不說這樣列舉會增加多大的工作量,光這漢字之多,能列舉的完嗎?

建立乙個pinyinhelper類,引入microsoft.international.converters.pinyinconverter命名空間。**:

public

static

class pinyinhelper

chinesechar chinesechar = new chinesechar(c);

} return result.tostring();

} }

要轉拼音時,呼叫這個類裡面的方法,將需要轉換的文字傳過去就行了。試了很多生僻字,完全沒問題。簡單易用又輕便。

中文轉拼音

中文轉拼音的類c 實現 code using system using system.collections.generic using system.text using system.collections endregion 獲得漢字的拼音,如果輸入的是英文本元將原樣輸出,中文標點符號將被忽略...

C 中文轉拼音的類

using system using system.collections.generic using system.text using system.collections endregion 獲得漢字的拼音,如果輸入的是英文本元將原樣輸出,中文標點符號將被忽略 漢字字串 拼音 static p...

Flex中文轉拼音

package return ret param char unicode格式的乙個中文字元 return 中文字元的聲母 example var chinesechar string 我 var py string convert.convertchar chinesechar trace py ...