CPinyin unicode汉字查找拼音(支持多音字)
---------------------------------------------------------------------------------
虽然很笨的办法,却非常有效
---------------------------------------------------------------------------------
Pinyin.h
---------------------------------------------------------------------------------
#pragma onceclass CPinyin
{
public:
CPinyin(void);
~CPinyin(void);
private:
CStringArray m_pyDataArray;
CString m_DataFileName;
bool m_isLoad;public:
bool LoadData(void);
bool LoadData( CString strFileName );
CString toPinyin(CString szHanzi, int iMode=0, CString szSplit=_T(" "), CString szDuoyinziSplit=_T(",") );
};
---------------------------------------------------------------------------------
Pinyin.cpp
---------------------------------------------------------------------------------
#include "StdAfx.h"
#include "Pinyin.h"
CPinyin::CPinyin()
{
m_DataFileName = _T("PinYinData_Unicode.txt");
LoadData();
}CPinyin::~CPinyin()
{
m_pyDataArray.RemoveAll();
}bool CPinyin::LoadData( CString strFileName )
{
m_DataFileName = strFileName;
return LoadData();
}bool CPinyin::LoadData(void)
{
CFile f;
CString str = _T("");
int i = 0;
int icnt = 0;
m_isLoad = false;m_pyDataArray.RemoveAll();
if( f.Open( m_DataFileName , CFile::modeRead ) )
{
f.Seek( 2L, CFile::begin); //unicode text file keep FF FE
UINT size = (UINT)f.GetLength()-2;
TCHAR *pData = (TCHAR *)malloc( size );
if( pData != NULL )
{
f.Read( pData, size);
while(AfxExtractSubString(str,pData,i,','))
{
++i;
if( str.GetLength() > 0 )
{
str.Replace(_T(" "),_T(""));
str.Replace(_T("\r\n"),_T(""));
m_pyDataArray.Add ( str );
icnt ++;
}
}
free( pData );
}
f.Close();
}
if( icnt > 0 ) m_isLoad = true;
return m_isLoad;
}//iMode 0 不显示多音字
// 1 显示多音字
CString CPinyin::toPinyin(CString szHanzi, int iMode, CString szSplit, CString szDuoyinziSplit )
{
int i = 0, j = 0, p1 = 0;
CString strPY = _T(""), str, strOneLine, strTmp, strHZData = _T("");
int iLen = szHanzi.GetLength();
if( iLen = 0 )
{
strHZData = strOneLine.Right(strOneLine.GetLength() - p1);
}
if( strHZData.Find( str ) != -1 )
{
isFindPinyin = true;
p1 = strOneLine.Find(_T(":"));
if( p1 > 0 )
{
strTmp = strOneLine.Left( p1 );
if( iduoyingzi > 0 )
{
if( iMode == 1 )
{
if( strPY.GetLength() > 0)
strPY += szDuoyinziSplit + strTmp;
else
strPY += strTmp;
}
}
else
{
if( strPY.GetLength()
下载代码CPinyin unicode汉字查找拼音(支持多音字)的更多相关文章
- C# 汉字转拼音(支持GB2312字符集中所有汉字)
GB2312标准共收录6763个汉字,其中一级汉字3755个,二级汉字3008个. 分区表示 GB 2312中对所收汉字进行了“分区”处理,每区含有94个汉字/符号.这种表示方式也称为区位码. )- ...
- C#汉字转拼音(支持多音字)
之前由于项目需要,中间需要一个汉字转拼音和首拼的功能来做查询,感觉这种功能基本已经成熟化了,于是查找了相关的代码,首先引入眼帘的是下面两篇文章 1.C# 汉字转拼音(支持GB2312字符集中所有汉字) ...
- JavaScript 汉字与拼音互转终极方案 附JS拼音输入法
转:http://www.codeceo.com/article/javascript-pinyin.html 前言 网上关于JS实现汉字和拼音互转的文章很多,但是比较杂乱,都是互相抄来抄去,而且有的 ...
- 【干货】JS版汉字与拼音互转终极方案,附简单的JS拼音输入法
前言 网上关于JS实现汉字和拼音互转的文章很多,但是比较杂乱,都是互相抄来抄去,而且有的不支持多音字,有的不支持声调,有的字典文件太大,还比如有时候我仅仅是需要获取汉字拼音首字母却要引入200kb的字 ...
- JS版汉字与拼音互转终极方案,附简单的JS拼音输入法
原文:http://www.cnblogs.com/liuxianan/p/pinyinjs.html 前言 网上关于JS实现汉字和拼音互转的文章很多,但是比较杂乱,都是互相抄来抄去,而且有的不支持多 ...
- JS版汉字与拼音互转终极方案,附简单的JS拼音
前言 网上关于JS实现汉字和拼音互转的文章很多,但是比较杂乱,都是互相抄来抄去,而且有的不支持多音字,有的不支持声调,有的字典文件太大,还比如有时候我仅仅是需要获取汉字拼音首字母却要引入200kb的字 ...
- AutoCompleteTextView输入汉字拼音首字母实现过滤提示(支持多音字,Filterable的使用)
AutoCompleteTextView具有输入提示的功能,但是它的这种提示不适合对股票列表的过滤,如果你玩过股票软件,就会知道只要输入股票名称的首字母或股票代码就会出现符合匹配的股票,这种过滤怎么实 ...
- SQL汉字转拼音函数-支持首字母、全拼
SQL汉字转拼音函数-支持首字母.全拼 FROM :http://my.oschina.net/ind/blog/191659 作者不详 --方法一sqlserver汉字转拼音首字母 --调用方法 s ...
- Windows API方式直接调用C#的DLL,支持多音字转拼音、Gzip解压缩、公式计算(VBA、C++、VB、Delphi甚至java都可以)
原始链接 https://www.cnblogs.com/Charltsing/p/DllExport.html 这两年,我在VBA应用方面一直有几大痛点:1.多音字转拼音:2.64位下的GZIP解压 ...
随机推荐
- struts2中怎么把action中的值传递到jsp页面
对于如何把struts2的action中的值传到jsp页面中,主要的方法有2种: 使用转发视图利用request域中储存所需的值 使用重定向时存储数据进入session使其在jsp中可以获得 下面,让 ...
- jQuery 文本编辑器插件 HtmlBox 使用
0.htmlbox下载地址:http://download.csdn.net/detail/leixiaohua1020/6376479 1.引入头文件 <script src="li ...
- 【CodeForces 602C】H - Approximating a Constant Range(dijk)
Description through n) and m bidirectional railways. There is also an absurdly simple road network — ...
- 【CodeForces 622A】Infinite Sequence
题意 一个序列是, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5....这样排的,求第n个是什么数字. 分析 第n个位置属于1到k,求出k,然后n-i*(i-1)/ ...
- jquery插件实现上下滑动翻页效果
<!DOCTYPE > <meta charset="utf-8" /> <head> <title>测试jquery</ti ...
- Protocol Buffer技术详解(数据编码)
Protocol Buffer技术详解(数据编码) 之前已经发了三篇有关Protocol Buffer的技术博客,其中第一篇介绍了Protocol Buffer的语言规范,而后两篇则分别基于C++和J ...
- 安装hadoop2.4.0遇到的问题
一.执行start-dfs.sh后,datenode没有启动 查看日志如下: 2014-06-18 20:34:59,622 FATAL org.apache.hadoop.hdfs.server.d ...
- Javascript动态调整文章的行距、字体、颜色,及打印页面和关闭窗口功能
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 网页中Javascript获取时间
<script language="javascript"> <!-- function initArray() { for(i=0;i<initArray ...
- mono 3.4.0 make install的时候出现"找不到 Microsoft.Portable.Common.targets 文件”的错误提示解决方法
如果在这时就进行配置安装Mono的话,会在make阶段得到一个“找不到 Microsoft.Portable.Common.targets 文件”的错误提示, 所以需要先进行如下处理: #> c ...