c语言 获取中文首字母,C语言获取汉字拼音首字母

  • Post author:
  • Post category:其他


在网络上找了一份C语言获取汉字拼音首字母的源程序,先保存一下。这里用了glib里面的一个函数g_convert。

#include

#include

#include

#include

gchar getpychar(guchar uword0 , guchar uword1)

{

gchar pychar;

int i1 = (short)(uword0 – ‘\0’);

int i2 = (short)(uword1 – ‘\0’);

int tmp = i1 * 256 + i2;

if(tmp >= 45217 && tmp <= 45252) pychar = ‘A’;

else if(tmp >= 45253 && tmp <= 45760) pychar = ‘B’;

else if(tmp >= 45761 && tmp <= 46317) pychar = ‘C’;

else if(tmp >= 46318 && tmp <= 46825) pychar = ‘D’;

else if(tmp >= 46826 && tmp <= 47009) pychar = ‘E’;

else if(tmp >= 47010 && tmp <= 47296) pychar = ‘F’;

els