My very first open source project[1] aimed to solve the same problem. Nice to see it still has quite a few weekly downloads.
[1] https://sourceforge.net/projects/bin2c/