MapAbc学习笔记

 Msearch 查询内容unsigned short 转化字符串输出  把网上能查的都查了,还是没找到,终于在网友棋剑千秋的帮助下,再次表示感谢,解决了这个问题终于可以大喘一口气了

inline void UnicodeToUTF8(unsigned char *Dst, int &nDst, unsigned short *Src)

{

unsigned char *DstE = Dst + nDst;

unsigned char *DstS = Dst;

unsigned short u;

while((u = *Src++) !=0 && Dst < DstE)

{

int c;

if (u < 0x80)

c = 1;

else if (u < 0x800)

c = 2;

#ifdef _SUPPORT_32BIT_UNICODE_

else if (u < 0x10000)

c = 3;

else if (u < 0x200000)

c = 4;

else if (u < 0x4000000)

c = 5;

else

c = 6;

#else

else

c = 3;

#endif

switch(c)

{

#ifdef _SUPPORT_32BIT_UNICODE_

case 6: Dst[5] = (unsigned char)(0x80 | (u & 0x3f)); u >>= 6; u |= 0x4000000;

case 5: Dst[4] = (unsigned char)(0x80 | (u & 0x3f)); u >>= 6; u |= 0x200000;

case 4: Dst[3] = (unsigned char)(0x80 | (u & 0x3f)); u >>= 6; u |= 0x10000;

#endif

case 3: Dst[2] = (unsigned char)(0x80 | (u & 0x3f)); u >>= 6; u |= 0x800;

case 2: Dst[1] = (unsigned char)(0x80 | (u & 0x3f)); u >>= 6; u |= 0xc0;

case 1: Dst[0] = (unsigned char)u;

}

Dst += c;

}

if (Dst < DstE)

*Dst++ = 0;

nDst = Dst - DstS;

}

调用

 int len=128*2;

    char cInfo[128] = {0};

    memset(cInfo, 0, sizeof(cInfo));

    UnicodeToUTF8((unsigned char*)cInfo,len,(info->pPois)->cName);

    NSString *poiName = [NSString stringWithUTF8String:cInfo];

你可能感兴趣的:(unsigned,short,转化字符串输出,Msearch,查询内容)