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.
 
 
 
 

28 lines
479 B

  1. #include "fmt.h"
  2. #ifdef UNITTEST
  3. #undef UNITTEST
  4. #include "fmt_tohex.c"
  5. #define UNITTEST
  6. #endif
  7. size_t fmt_escapecharquotedprintable(char* dest,uint32_t ch) {
  8. if (ch>0xff) return 0;
  9. if (dest) {
  10. dest[0]='=';
  11. dest[2]=fmt_tohex(ch&0xf); ch>>=4;
  12. dest[1]=fmt_tohex(ch&0xf);
  13. }
  14. return 3;
  15. }
  16. #ifdef UNITTEST
  17. #include <assert.h>
  18. #include <string.h>
  19. int main() {
  20. char buf[100];
  21. assert(fmt_escapecharquotedprintable(buf,'f')==3 && !memcmp(buf,"=66",3));
  22. }
  23. #endif