MCPcopy Create free account
hub / github.com/EasyIME/PIME / encode_base64

Function encode_base64

installer/inetc/Contrib/Inetc/inetc.cpp:305–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305TCHAR *encode_base64(int size, TCHAR *src, TCHAR *dst) {
306
307 int i;
308 TCHAR *p;
309
310 if(!src)
311 return NULL;
312
313 if(!size)
314 size= lstrlen(src);
315
316 p = dst;
317
318 for(i=0; i<size; i+=3) {
319
320 unsigned char b1=0, b2=0, b3=0, b4=0, b5=0, b6=0, b7=0;
321
322 b1 = (unsigned char)src[i];
323
324 if(i+1<size)
325 b2 = (unsigned char)src[i+1];
326
327 if(i+2<size)
328 b3 = (unsigned char)src[i+2];
329
330 b4= b1>>2;
331 b5= ((b1&0x3)<<4)|(b2>>4);
332 b6= ((b2&0xf)<<2)|(b3>>6);
333 b7= b3&0x3f;
334
335 *p++= encode(b4);
336 *p++= encode(b5);
337
338 if(i+1<size) {
339 *p++= encode(b6);
340 } else {
341 *p++= TEXT('=');
342 }
343
344 if(i+2<size) {
345 *p++= encode(b7);
346 } else {
347 *p++= TEXT('=');
348 }
349
350 }
351
352 return dst;
353}
354
355/*****************************************************
356* FUNCTION NAME: fileTransfer()

Callers 2

inetTransferFunction · 0.85
getFunction · 0.85

Calls 1

encodeFunction · 0.85

Tested by

no test coverage detected