バイナリ文字列コード


typedef char     s8;
typedef unsigned char   u8;
typedef short           s16;
typedef unsigned short  u16;
typedef int    s32;
typedef unsigned long    ulong;





s32 uti_text2hex(s8* pszBodyIn, s8* pszBodyOut)
{
 s8 buffer[20];
 s32 cnt = 0;
 s32 ret = 0;
 s8* pSzMsg = NULL;
 pSzMsg = pszBodyIn;
 for (cnt = 0; cnt < strlen(pszBodyIn) / 2; cnt++)
 {
  s32 nOffset = 0;
  memset(buffer, 0, 20);
  if (*pSzMsg == ' ')
  {
   pSzMsg++;
  }
  strncpy(buffer, pSzMsg, 2);
  pSzMsg += 2;
  ret = strtoul(buffer, NULL, 16);
  memcpy(pszBodyOut + cnt, &ret, sizeof(int));
 }

 return cnt;
}