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解压 ...
随机推荐
- linux中为什么已经是root用户仍不能执行程序
.sh文件 ,获取root权限,提示Permission Denied. 这是因为文件本身没有可执行特性. chmod +x a.sh chmod 755 a.sh
- POJ3233 Matrix Power Series
Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak. ...
- codeforces 58E:Expression
Description One day Vasya was solving arithmetical problems. He wrote down an expression a + b = c i ...
- javascript设计模式-装饰模式
装饰模式:在不改变原类(对象)和继承的情况下动态扩展对象功能,通过包装一个对象来实现一个新的具有原对象相同接口的新的对象.在设计原则中,有一条,多用组合,少用继承,装饰模式正是这一原则的体现. UML ...
- Maven学习笔记-03-Eclipse下maven项目在Tomcat7和Jetty6中部署调试
现在最新的Eclipse Luna Release 已经内置了Maven插件,这让我们的工作简洁了不少,只要把项目直接导入就可以,不用考虑插件什么的问题,但是导入之后的项目既可以部署在Tomcat也可 ...
- HD 1011 Starship Troopers(树上的背包)
Starship Troopers Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- Knockout Grid - Loading Remote Data
http://wijmo.com/grid-with-knockout-viewmodel-loading-remote-data/ We were hearing quite a few peopl ...
- form表单只提交数据而不进行页面跳转的解决方案
一般的form提交操作写法为 代码如下: <form action="saveReport.htm" method="post"> …… <i ...
- php网站验证码的生成
<?php header("Content-type:text/html;charset=utf-8"); header("Content-type:image/p ...
- nginx proxy超时报错 upstream timed out (110: Connec...
环境介绍 服务器:centos6.4服务:nginx proxy 问题描述: 然后查找 /opt/usr/nginx/1.4.0/logs 错误 error.log日志提示如下 2015/01/0 ...