回复 3# pd1
大佬能指导下吗?
我没有装VS,看了点教程用Tcc编译, 会报下面的错误,
tcc: undefined symbol 'isascii'
我把报错的(// 排除askii 码 )那几行代码删了, 能编译成功, 但是在PS中执行又报下面的错误
Add-Type : c:\Users\Administrator\AppData\Local\Temp\30bxsszt\30bxsszt.0.cs(4) : 无法识别的转义序列
下面是编译的C代码前面的部分, 贴全部就超长了- #include <string.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <ctype.h>
-
- #define EXPORT __declspec(dllexport)
- #define MAXBUFLEN 1024
-
- enum PinyinMode{
- enmPinyinMode_AllUpper = 0, //全大写
- enmPinyinMode_AllLower, //全小写
- enmPinyinMode_FirstUpper, //首字母大写
- };
-
- const char* getPinyinByCode(uint32_t code);
- void getPinyin(const char* szChinese,char pinyinBuf[],const uint32_t maxBufLen,uint32_t *bufLen,const uint32_t mode);
-
- EXPORT void h2p(const char* szChinese)
- {
- uint32_t bufLen = 0;
- char pinyinBuf[MAXBUFLEN] = { 0 };
- //const char* szChinese = "中华人民共和国 People's Republic of China";
- getPinyin(szChinese, pinyinBuf, MAXBUFLEN, &bufLen, enmPinyinMode_FirstUpper);
- printf("%s\n", pinyinBuf);
- }
-
- void getPinyin(const char* szChinese,char pinyinBuf[],const uint32_t maxBufLen,uint32_t *bufLen,const uint32_t mode)
- {
- *bufLen = 0;
- uint8_t ucHigh, ucLow;
- uint32_t code,i,j;
- const uint32_t chineseLen = strlen(szChinese);
- for (i = 0; i<chineseLen;++i )
- {
- uint8_t c = szChinese[i];
- // 排除askii 码
- if (isascii(c))
- {
- pinyinBuf[(*bufLen)++] = c;
- continue;
- }
- ucHigh = (uint8_t)szChinese[i];
- ucLow = (uint8_t)szChinese[++i];
- if ( ucHigh <= 0xa0 || ucLow <= 0xa0 )
- {
- continue;
- }
- else
- {
- code = (ucHigh - 0xa0) * 100 + ucLow - 0xa0;
- }
- const char* pBuf = getPinyinByCode(code);
- for (j = 0; j < strlen(pBuf) && (*bufLen) < maxBufLen; ++j)
- {
- char cc = pBuf[j];
- switch(mode)
- {
- case enmPinyinMode_AllUpper:break;
- case enmPinyinMode_AllLower:cc = tolower(cc);break;
- case enmPinyinMode_FirstUpper:if(j!=0)cc = tolower(cc);break;
- }
- pinyinBuf[(*bufLen)++] = cc;
- }
- }
- }
-
- }
复制代码
|