Dim kamei As String = "あ,い,う,え,お,か,き,く...." '定义一个字符串,保存所有假名 Dim kameiSplit() As String = kamei.Split(",") For Each tempStr As String In kameiSplit If InStr(strtisiki, tempStr) <> 0 Then flag = 1 Dim str1 As String = strtisiki.ToString Dim strbytes As Byte() = Encoding.Default.GetBytes(str1) Dim str2 As String = Encoding.GetEncoding(932).GetString(strbytes) If str1 <> str2 Then flag = 2 End If Exit For Else flag = 0 End If Next
另外,用iconv进行转化,遇到非日语的字符,默认会截断字符串。
http://www.singlestudio.net.cn/cnjp/x/
这个,我也是利用了另一个站点的数据才做出来的效果。
凡是没有假名的,就是纯粹的中文汉字。
Dim kameiSplit() As String = kamei.Split(",")
For Each tempStr As String In kameiSplit
If InStr(strtisiki, tempStr) <> 0 Then
flag = 1
Dim str1 As String = strtisiki.ToString
Dim strbytes As Byte() = Encoding.Default.GetBytes(str1)
Dim str2 As String = Encoding.GetEncoding(932).GetString(strbytes)
If str1 <> str2 Then
flag = 2
End If
Exit For
Else
flag = 0
End If
Next
$strb = '私は音楽が上手です '; //判断为 other $pat = "/^[\x80-\xff_a-zA-Z0-9]+$/";
if( preg_match($pat,$stra) )
echo 'chinese ...';
else
echo 'other ... ';
//由此看来, 要切词之后一个个来匹配, 才分辨出是否纯中文,纯日文
csdn上也有http://blog.csdn.net/liuzongshun/archive/2009/05/26/4216403.aspx
==========================================================
欢迎加入以google wave为交流工具的PHP讨论组: [email protected]
加入办法:
1。 从你的gmail可以直接发信到 [email protected]
2。 PM你的邮箱给我,我直接加入
3。 到http://groups.google.com/group/phpwave/subscribe?note=1申请
如果该网址不能访问请尝试 https://groups.google.com/group/phpwave/subscribe?note=1
或 http://groups.google.co.uk/group/phpwave/subscribe?note=1 ...(或换其它国家域名)
$mydata="Excel中有一列数据是用公式求出来的,怎样才能把这一列数据拷贝出来。Eclipse中,JSP文件的Java代码无语法着色,怎么解决呢?";
// do the segment
$ignore=true; //定义清除标点符号的变量$ignore
$cws = scws_new();
$cws->set_ignore($ignore);//清除标点符
//scws_set_charset('gbk');
$cws->set_charset('utf8');
// use default dictionary & rules
$cws->send_text($mydata);
echo $mydata."<br>";
echo "<hr>";
$res = $cws->get_result();
print_r($res);
echo"<hr>";
$res = $cws->get_result();
print_r($res);
echo"<hr>";
$res = $cws->get_result();
print_r($res);die; while ($res = $cws->get_result())
{
//print_r($res);
//echo"<hr>";
//foreach ($res as $tmp)
//{ if(count(explode("n",$tmp['attr']))>1)
// printf("%s/%s", $tmp['word'], $tmp['attr']);
// print " ";
//}
foreach ($res as $a=>$tmp)
{
echo "<font color= red>".$a."</font>";
echo "<hr color=green width =88 align=left>";
foreach($tmp as $aa=>$as)
{
echo $as."--";
}
echo "<br>";
}
flush();
}
echo"<hr size=9>";
print_r($res);
$cws->close();
?>
error_reporting(0);
$dbconn = pg_connect("host=localhost port=5432 dbname=test1 user=postgres password=ryouka") or die("can not connect the database");
pg_query("set names UTF8");$file_name="Test_1.txt";
$fp=fopen($file_name,'r');
while(!feof($fp))
{
//echo"<hr>";
$buffer=fgets($fp,4096);
//$buffer=addslashes($buffer);
$a=explode("---",$buffer);
$xx=trim($a[0]);
$yy=trim($a[1]);
$zz=trim($a[2]);
//echo strlen($a[0]);
pg_query("insert into thread (id,title,question) values('$xx','$yy','$zz')");
//echo $a[0];
}
fclose($fp);
$b=pg_query("select * from d") or die("<br>表d不存在,查询失败!".mysql_error());$sum=pg_num_rows($b);
echo "总记录数".$sum."<br>";
echo"<table border=1><tr>";
echo"<td width=81 bgcolor=#FFBB77>知識ID</td>";
echo"<td width=281 bgcolor=#FFBB77 align=center>知識全文</td>";
//echo"<td>チーム</td>";
//echo"<td>経験</td>";
//echo"<td>学歴</td>";
//echo"<td>問題大分類</td>";
//echo"<td>問題小分類</td>";
echo"<td width=181 bgcolor=#FFBB77 align=center>名前</td></tr>";
//echo"<td>提出年月</td>";
//echo"<td>アクセス数</td>";
//echo"<td>記入状況</td>";
//echo"<td>職務</td></tr>";
//die;
for($i=0;$i<400;$i++)
{//echo "ok";
$x=pg_fetch_array($b);
if ($x[1]<>"")
{
echo"<tr><td width=81 bgcolor=#97CBFF><font color=red>$x[0]</font></td><td width=281><font color=#8F4586>$x[1]</font></td><td width=181>$x[6]</td></tr>";
}
}echo"</table>";pg_close();//echo $dbconn;
?>