在数据库中查找中文~

standlove 2003-11-13 09:19:26

现在要在一个 中英 夹杂的文件中读取中文字,
需要分离出中文字, 然后在数据库统计这个字出现的频率,
请问 如何分离中文字 以及 如何 编写查询语句。

thx ~ bcb ..
...全文
41 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
chifengwatch 2003-11-14
  • 打赏
  • 举报
回复
select * from 表 where col like '%中文%'
chifengwatch 2003-11-14
  • 打赏
  • 举报
回复
Header File

ctype.h

Category

Classification Routines

Syntax

#include <ctype.h>
int isascii(int c);
int iswascii(wint_t c);

Description

Character classification macro.

These functions depend on the LC_CTYPE

isascii is a macro that classifies ASCII-coded integer values by table lookup. It is a predicate returning nonzero for true and 0 for false.

isascii is defined on all integer values.

Return Value

isascii returns nonzero if c is in the range 0 to 127 (0x00-0x7F).

iswascii returns nonzero if c is is a wide-character representation of an ASCII character.

Each of these routines returns 0 if c does not satisfy the test condition.
chifengwatch 2003-11-14
  • 打赏
  • 举报
回复
AnsiString enStr = "" ;//英文
AnsiString cnStr = "" ;//中文
WideString wideStr ="abc汉字def字ghi数jkl统计mno" ;
for ( int i = 0 ; i < wideStr.Length() ; i++ )
{
if ( ( AnsiString( wideStr.SubString( i + 1 , 1 ) ) ).Length() == 2 )
{
cnStr += wideStr.SubString( i + 1 , 1 ) ;
}
else
{
enStr += wideStr.SubString( i + 1 , 1 ) ;
}
}
chenqm 2003-11-13
  • 打赏
  • 举报
回复
void __fastcall TForm1::Button1Click(TObject *Sender)
{int i=0;
long SUM=0;//汉字字数统计
char s[128]="dvfdsg汉字csdgvd字hgrth数vdfg统计";
for(i=0; i<StrLen(s);i++)
{if(s[i]<0) //是汉字
{SUM++;
i++;
}
}
ShowMessage(SUM);
}
standlove 2003-11-13
  • 打赏
  • 举报
回复

希望扫描一遍就把所有的汉字挑出来,
另外如果可以把英文挑出来, 那么挑汉字的方法应该是一样的吧。
请问: 如何区分某个字节是 英文 还是汉字的一部分?

要处理不止一个文本~
另外: 汉字是保存成 short int 还是 char[2] 好?
不过查询的时候一定要转换成 string 的.......
freshman2003 2003-11-13
  • 打赏
  • 举报
回复
除了英文就是中文,把英文挑出来好挑,剩下的就是中文了。
如果建立数据库纯粹是要统计字出现的频率的话,完全可以不建这个库,你可以建立一个二维动态数组用于存放字和字出现的次数,找到和存于数组中相同的字以后对应值加1就行。

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧