惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - 古代

linux下关于重命名卷标 wget header参数使用。 - 古代 - 博客园 奔波尔霸温瑞安 方娥真〈月台〉析论 入凡尘十二年的方娥真 模拟兼容onmouseleave,onmouseenter - 古代 - 博客园 python 进程通信测试代码(程序A,程序B) parse_url 和再pathinfo,what you'll get - 古代 autopos php转换拼音,全。 RPM 安装mod_encoding,linux下apache支持中文名 自动杀死pps的后台进程 js表达式转义 - 古代 - 博客园 批量jstest get_top_dom($dom); - 古代 - 博客园 rm大量文件 Read-only file system处理记录 唉,这个备案,头疼. 神奇的js代码,图片全都飞起来了
通过PHP获取生僻字的汉语拼音[转]
古代 · 2009-11-04 · via 博客园 - 古代

最近使用到汉字到拼音的转换,因此在众多搜索结果干扰项中探得此文。由于原文思路清晰,观点独特,故转载于此。本文实质上使用的是查表法,全文内容基本上是字典的获取方法
注意:本文转自 http://blog.verycd.com/dash/cmd=showentry&eid=1677 ,以下为原文

      细心的网友可能会发现,VeryCD的资源搜索是支持拼音的,不论你是直接输入拼音,还是输入同音字,我们的搜索程序都会提示你正确的关键字。比如: http://search.verycd.com/search?q=萧雅轩 (注:此链接已经过时)
之前我们使用的是一个网上已经很普遍的汉字转拼音函数,通过使用后发现,这个函数的算法虽然简便,但只能取得GB2312中根据拼音排列的3755个常用汉字,所以其适用范围很有限。由于其它汉字大都按部首/笔画顺序排列,所以我们只能通过建立一个汉字-拼音表来实现一一对应。
这个时候输入法生成器就派上了用场,利用它的逆转换功能生成一个汉字拼音的文本文件。然后再写一个PHP小程序,即可删除这个文本文件中的词组和多音字。

 <?php
//注意,在2000/XP下生成的文本文件是Unicode格式,需要先转换到GB2312
$py = file_get_contents("WINPY.TXT");
$py = mb_convert_encoding( $py , "GBK" , "UCS-2" );
$arr_tmp = explode("\r\n", $py);
$arr_py = array();
foreach ($arr_tmp as $v)
{
   if (preg_match("/^[".chr(0x81)."-".chr(0xfe)."].[a-z]/", $v , $m ))
   {
    //print_R($m);die;
       $word = substr($v, 0, 2);
       if (!$arr_py[$word])
       {
           $arr_py[$word] = substr($v, 2);
           $output .= $v."\n";
       }
   }
}
$handle = fopen("WINPY2.TXT", 'w');
fwrite($handle, $output);
?>

      通过读入WINPY2.TXT再配合几个字符串操作函数就可以非常简单的获取到汉字的拼音了(具体的代码xdanger还在写,我这里就不贴出来了)

      附注:我们在最后处理的时候忽略了多音字的因素,以后仍然有待改进。
      网上关于正则判断中文的文章大都使用[chr(0xa1)-chr(0xff)]来判断中文,事实上这只能判断出GB2312的几千个汉字,生僻字和繁体字都不包含在内,正确的应该是[chr(0x81)-chr(0xfe)]。

对于WINXP请大家打开 C:\windows 目录, 查找 imegen.exe ,和 .MB , 找到 WINPY.MB