bin2cEX

bin2cEX is a program that converts binary data into a C valid array.

Used to import your resource files directly into your program.
Examples: textures, sounds, characters maps, etc.

Usage:

bin2cEX [input_file_path] [output_file_path] [array_name] [args...]

bin2cEX has 3 different output types: array in single file, array proto in header + array in source file, array data only in a single file.


Use case:

In SimpleVolumeMixer I needed to load the font glyphs for non-ASCII UTF8 characters: some symbols, some kanji and kana.
But C and C++ support for UTF8 characters in string literals, at the time I'm writing this (2025), is to be honest, dogshit.
So I've got the idea to write a plain text file with all the UTF8 characters that I needed, because it's easier to edit:

// utf8_charmap ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!"#$%&'()*+,-./\:;<=>?@[]^_{|}~‘’“”„•§©®™⁰¹²³⁴⁵⁶⁷⁸⁹

// utf8_charmap_ja あいうえおかきくけこがぎぐげごさしすせそざじずぜぞたちつてとだぢづでどなにぬねのはひふへほばびぶべぼぱぴぷぺぽまみむめもやゆよらりるれろわをんゃゅょゎっアイウエオカキクケコガギグゲゴサシスセソザジズゼゾタチツテトダヂヅデドナニヌ ネノハヒフヘホバビブベボパピプペポマミムメモヤユヨラリルレロワヲンャュョヮッ。、、?!「」『』()【】〝〟ー々― 〠※一二三四五六七八九十百千万上下左右中大小川山女男女子先生年目口目耳手足体内外水火木金土天空正早友力心電話食学校店時日月年明 暗立歩死生学使売購買貸借決計賞成立使上進退長短強弱忘会語死食明用近遠転寝開閉出入止行来見思記何読書習見覚難簡倍積速遅話明結休直売品受供支払起着増減関現上下大小二三平山川左右正直明日教進終開始安社動計

We can now generate our C array data with the help of bin2cEX:

bin2cEX.exe utf8_charmap utf8_charmap.c utf8_charmap -output_type raw_array_data_file bin2cEX.exe utf8_charmap_ja utf8_charmap_ja.c utf8_charmap_ja -output_type raw_array_data_file

Then I'm able to include the generated array data into my code:

u8 UTF8_CHARMAP_DATA[] = { #include "utf8_charmap.c" , // Unfortunately I cannot put the comma on the same line as the preprocessor directive "include" (tested on MSVC). #include "utf8_charmap_ja.c" }; utf8_font_characters UTF8_FONT_CHARMAP = { .data = UTF8_CHARMAP_DATA, .count = utf8_buf_count(UTF8_CHARMAP_DATA, sizeof(UTF8_CHARMAP_DATA)) // Counts the number of UTF8 characters. }; if (!upload_font_in_filesystem_to_gpu( &font_path, 14 /* pixel height */, &UTF8_FONT_CHARMAP, &out_font_glyphs, &out_font_gpu, allocator ) ) { LOG_ERROR("Failed to load font."); return 0; }


Download: