CString 十六進制數據 轉換 int UNICODE & ANSI

CString  lowstr ="FF";

///////////////////////////////////////////////////////////////////////////////////////////  

//unicode

 int L = lowstr.GetLength();
   int sum(0),temp(0);
   for (int i = 0; i <= L;i++)
   {
    swscanf_s(lowstr.Mid(i,1),_T("%x"),&temp);//swscanf_s  unicode編碼
    sum += temp*(pow(16,(L-1.0-i)));//pow   double
   }

 

///////////////////////////////////////////////////////////////////////////////////////////  

//ANSI

   char *p=(LPSTR)(LPCTSTR)lowstr; 
   char *str;  
   int lowvalue = (int)strtol(p, &str, 16);//十六進制

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章