char* utf8_to_gb2312(char* inbuf)
{
int inlen = strlen(inbuf);
iconv_t cd = iconv_open("gb2312", "utf-8");
if ((iconv_t)-1 == cd)
{
perror("iconv_open"); return NULL;
}
char *outbuf = (char *)malloc(inlen * 4 );
bzero( outbuf, inlen * 4);
char *in = inbuf;
char *out = outbuf;
size_t outlen = inlen *4;
iconv(cd, &in, (size_t *)&inlen, &out,&outlen);
outlen = strlen(outbuf);
//printf("%s\n",outbuf);
//free(outbuf);
iconv_close(cd);
return outbuf;
}
void show_cdu(char* buf)
{
char* inbuf = buf;
char* outbuf = utf8_to_gb2312(inbuf);
CDisp_Clr_688_3();
CDisp_Setfont_688_3(1);
CDisp_Set_Abs_XY_688_3(1,1);
CDisp_String_688_3((unsigned char*)outbuf);
CDisp_Start_688_3();
free(outbuf);
return;
}
下面是播放声音的脚本:
#!/bin/bash
par1=`tr '[a-z]' '[A-Z]' <<< "$1"`
if [ $par1 = "PLAY" ]
then
/cqcp/bin/pSound -r 48000 -b 8 -c 2 -f /cqcp/resources/succ.wav
fi
if [ $par1 = "STOP" ]
then
tpid=`ps -ef | grep succ.wav | grep -v grep | awk '{print $2}'`
kill -9 $tpid
fi
if [ $par1 = "VOL" ]
then
echo $2 > mute
if [ $2 -eq 0 ]; then
amixer set Master 0% mute
else
amixer set Master $2% unmute
fi
#./playSound dd.wav
#system("play xxx.wav");
#cat file /dev/dsp
#system("aumix xxxxxx")
fi