中文字符按拼音排序的问题。

hotjk 2002-07-22 02:33:46
中文字符按拼音排序的问题。
1。是不是要取得中文字符的unicode吗?如果是,敢问如何取得,若否,敢问如何排序。
2。最好是得到中文的拼音。
下载了一个袁飞拼音控件(ocx),可是在vc中没有GetPYFromHZ(strHz ,strPY()) as boolean这个函数了。
...全文
308 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jason_sun22 2002-07-22
  • 打赏
  • 举报
回复
直接Strcmp()就可以了呀!

它自动按照拼音排序的!
e2wugui 2002-07-22
  • 打赏
  • 举报
回复
Platform SDK: Windows User Interface
CompareString
The CompareString function compares two character strings, using the specified locale.

int CompareString(
LCID Locale, // locale identifier
DWORD dwCmpFlags, // comparison-style options
LPCTSTR lpString1, // first string
int cchCount1, // size of first string
LPCTSTR lpString2, // second string
int cchCount2 // size of second string
);
Lemon_2000 2002-07-22
  • 打赏
  • 举报
回复
使用说明:您需要的是调用GetPYChar这个函数。//来自一网友
例子:
char z= GetPYChar("中");//此时z为'Z'
char a=GetPYChar("爱");// 此时a为'A'

file://Code:
#include <assert.h>

file://功能:检测Value 是否在Lp..Hp之间
file://---------------------------------------------------------------------------
bool __fastcall In(int Lp, int Hp,int Value)
{
assert(Lp<=Hp);
return ((Value<=Hp)&&(Value>=Lp));
}

file://参数:一个汉字
file://返回值:该汉字的拼音
char __fastcall GetPYChar(AnsiString HZ)
{
assert(HZ.Length()==2);
WORD Hi=WORD(HZ[1])<<8;
WORD Lo=BYTE(HZ[2]);
int n=Hi+Lo;
if (In(0xB0A1,0xB0C4,n)) return 'A';
if (In(0XB0C5,0XB2C0,n)) return 'B';
if (In(0xB2C1,0xB4ED,n)) return 'C';
if (In(0xB4EE,0xB6E9,n)) return 'D';
if (In(0xB6EA,0xB7A1,n)) return 'E';
if (In(0xB7A2,0xB8c0,n)) return 'F';
if (In(0xB8C1,0xB9FD,n)) return 'G';
if (In(0xB9FE,0xBBF6,n)) return 'H';
if (In(0xBBF7,0xBFA5,n)) return 'J';
if (In(0xBFA6,0xC0AB,n)) return 'K';
if (In(0xC0AC,0xC2E7,n)) return 'L';
if (In(0xC2E8,0xC4C2,n)) return 'M';
if (In(0xC4C3,0xC5B5,n)) return 'N';
if (In(0xC5B6,0xC5BD,n)) return 'O';
if (In(0xC5BE,0xC6D9,n)) return 'P';
if (In(0xC6DA,0xC8BA,n)) return 'Q';
if (In(0xC8BB,0xC8F5,n)) return 'R';
if (In(0xC8F6,0xCBF0,n)) return 'S';
if (In(0xCBFA,0xCDD9,n)) return 'T';
if (In(0xCDDA,0xCEF3,n)) return 'W';
if (In(0xCEF4,0xD188,n)) return 'X';
if (In(0xD1B9,0xD4D0,n)) return 'Y';
if (In(0xD4D1,0xD7F9,n)) return 'Z';
return char(0);
}
xuying 2002-07-22
  • 打赏
  • 举报
回复
char中是汉字,返回改汉字的拼音首字母:

function getpychar(char)
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then getpychar= "A"
if(tmp>=45253 and tmp<=45760) then getpychar= "B"
if(tmp>=47761 and tmp<=46317) then getpychar= "C"
if(tmp>=46318 and tmp<=46825) then getpychar= "D"
if(tmp>=46826 and tmp<=47009) then getpychar= "E"
if(tmp>=47010 and tmp<=47296) then getpychar= "F"
if(tmp>=47297 and tmp<=47613) then getpychar= "G"
if(tmp>=47614 and tmp<=48118) then getpychar= "H"
if(tmp>=48119 and tmp<=49061) then getpychar= "J"
if(tmp>=49062 and tmp<=49323) then getpychar= "K"
if(tmp>=49324 and tmp<=49895) then getpychar= "L"
if(tmp>=49896 and tmp<=50370) then getpychar= "M"
if(tmp>=50371 and tmp<=50613) then getpychar= "N"
if(tmp>=50614 and tmp<=50621) then getpychar= "O"
if(tmp>=50622 and tmp<=50905) then getpychar= "P"
if(tmp>=50906 and tmp<=51386) then getpychar= "Q"
if(tmp>=51387 and tmp<=51445) then getpychar= "R"
if(tmp>=51446 and tmp<=52217) then getpychar= "S"
if(tmp>=52218 and tmp<=52697) then getpychar= "T"
if(tmp>=52698 and tmp<=52979) then getpychar= "W"
if(tmp>=52980 and tmp<=53640) then getpychar= "X"
if(tmp>=53689 and tmp<=54480) then getpychar= "Y"
if(tmp>=54481 and tmp<=52289) then getpychar= "Z"
end function

16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

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