bad char
[vg.git] / vg_binstr.c
1 #include "vg/vg_binstr.h"
2
3 void vg_str_bin( const void *txt, void *bin, int size )
4 {
5 const u8 *src = txt;
6 u8 *dst = bin;
7
8 for( u32 i=0; i<size/2; i++ ){
9 dst[i] = (src[i*2+0]-VG_BINSTR_BASECHAR);
10 dst[i] |= (src[i*2+1]-VG_BINSTR_BASECHAR)<<4u;
11 }
12 }
13
14 void vg_bin_str( const void *bin, void *txt, u32 size )
15 {
16 u8 *dst = txt;
17 const u8 *src = bin;
18
19 for( u32 i=0; i<size; i++ ){
20 dst[i*2+0] = VG_BINSTR_BASECHAR + ((src[i] ) & 0xf);
21 dst[i*2+1] = VG_BINSTR_BASECHAR + ((src[i]>>4u) & 0xf);
22 }
23 }