| 199 | |
| 200 | |
| 201 | void BinToHex(const byte *Bin,size_t BinSize,char *HexA,wchar *HexW,size_t HexSize) |
| 202 | { |
| 203 | uint A=0,W=0; // ASCII and Unicode hex output positions. |
| 204 | for (uint I=0;I<BinSize;I++) |
| 205 | { |
| 206 | uint High=Bin[I] >> 4; |
| 207 | uint Low=Bin[I] & 0xf; |
| 208 | uint HighHex=High>9 ? 'a'+High-10:'0'+High; |
| 209 | uint LowHex=Low>9 ? 'a'+Low-10:'0'+Low; |
| 210 | if (HexA!=NULL && A<HexSize-2) // Need space for 2 chars and final zero. |
| 211 | { |
| 212 | HexA[A++]=(char)HighHex; |
| 213 | HexA[A++]=(char)LowHex; |
| 214 | } |
| 215 | if (HexW!=NULL && W<HexSize-2) // Need space for 2 chars and final zero. |
| 216 | { |
| 217 | HexW[W++]=HighHex; |
| 218 | HexW[W++]=LowHex; |
| 219 | } |
| 220 | } |
| 221 | if (HexA!=NULL && HexSize>0) |
| 222 | HexA[A]=0; |
| 223 | if (HexW!=NULL && HexSize>0) |
| 224 | HexW[W]=0; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | #ifndef SFX_MODULE |
no outgoing calls