Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
581 B

  1. #include "fmt.h"
  2. #include "textcode.h"
  3. #include "haveinline.h"
  4. static inline int tohex(char c) {
  5. return c>9?c-10+'A':c+'0';
  6. }
  7. unsigned int fmt_quotedprintable(char* dest,const char* src,unsigned int len) {
  8. register const unsigned char* s=(const unsigned char*) src;
  9. unsigned long written=0,i;
  10. for (i=0; i<len; ++i) {
  11. if (s[i]&0x80 || s[i]=='=') {
  12. if (dest) {
  13. dest[written]='=';
  14. dest[written+1]=tohex(s[i]>>4);
  15. dest[written+2]=tohex(s[i]&15);
  16. }
  17. written+=3;
  18. } else {
  19. if (dest) dest[written]=s[i]; ++written;
  20. }
  21. }
  22. return written;
  23. }