Skip to main content
  • 产品
  • Evaluate our Software
  • 下载
  • Free Utilities
  • 购买
  • 支持
  • 关于我们
  • Search
    • Contact Us
    • Forum
    • Knowledge Base
    • Newsletter
    • RSS
  •   工作机会
  •   视频
  •   永续性
  • Bin2C
    placeholder height 250

    Bin2C—Binary to C Converter

    Bin2C is a command-line utility for Windows which takes a binary (or HTML or text) file as input and converts it to a C-array that can be directly included in target application code.

    1. 1.Using Bin2C
    2. 2.Example, Create C-File From Test.html
      1. 2.1.Content of test.html
      2. 2.2.Content of test.c
      3. 2.3.Content of test.h

    Bin2C does not require additional software to be installed (runs stand-alone). Typical usage applications are data that need to be included in a C-program,
    such as FPGA configuration data, bitmaps in portable format (such as GIF, PNG), web pages that need to be delivered by a built-in web server etc.

    Using Bin2C

    The Bin2C utility is very simple to use. It expects a path to an existing file as an input parameter as well as a path to an output file. The input file will be read as binary input data and output into a C-array in the output file. The C-array can be easily compiled into an application.

    If the utility is started without any file input, it will print its usage information.

    bin2c no input

    Example, Create C-File From Test.html

    The following command-line is used: Bin2C.exe test.html test

    This results in the following files

    • test.html
    • test.c
    • test.h

     

    Content of test.html

    <html>
      <head>
        <title>Testpage</title>
      </head>
      <body>
        <p>This is a test paragraph</p>
        <ol>
          <li>This is a test list entry 0</li>
          <li>This is a test list entry 1</li>
        </ol>
      </body>
    </html>

     

    Content of test.c

    /*********************************************************************
    *               SEGGER MICROCONTROLLER GmbH & Co. KG                 *
    *       Solutions for real time microcontroller applications         *
    **********************************************************************
    *                                                                    *
    *       (c) 2002 - 2015  SEGGER Microcontroller GmbH & Co. KG        *
    *                                                                    *
    *       www.segger.com     Support: support@segger.com               *
    *                                                                    *
    **********************************************************************
     
    ----------------------------------------------------------------------
    File    : test.c
    Purpose : Automatically created from test.html using Bin2C.exe
    --------  END-OF-HEADER  ---------------------------------------------
    */
    
    #include "test.h"
    const unsigned char test_file[198] =
    {
      0x3c,  0x68,  0x74,  0x6d,  0x6c,  0x3e,  0x0d,  0x0a,  0x3c,  0x68,
      0x65,  0x61,  0x64,  0x3e,  0x3c,  0x2f,  0x68,  0x65,  0x61,  0x64,
      0x3e,  0x0d,  0x0a,  0x3c,  0x74,  0x69,  0x74,  0x6c,  0x65,  0x3e,
      0x54,  0x65,  0x73,  0x74,  0x70,  0x61,  0x67,  0x65,  0x3c,  0x2f,
      0x74,  0x69,  0x74,  0x6c,  0x65,  0x3e,  0x0d,  0x0a,  0x3c,  0x62,
      0x6f,  0x64,  0x79,  0x3e,  0x0d,  0x0a,  0x3c,  0x70,  0x3e,  0x54,
      0x68,  0x69,  0x73,  0x20,  0x69,  0x73,  0x20,  0x61,  0x20,  0x74,
      0x65,  0x73,  0x74,  0x20,  0x70,  0x61,  0x72,  0x61,  0x67,  0x72,
      0x61,  0x70,  0x68,  0x3c,  0x2f,  0x70,  0x3e,  0x0d,  0x0a,  0x3c,
      0x6f,  0x6c,  0x3e,  0x0d,  0x0a,  0x20,  0x20,  0x3c,  0x6c,  0x69,
      0x3e,  0x54,  0x68,  0x69,  0x73,  0x20,  0x69,  0x73,  0x20,  0x61,
      0x20,  0x74,  0x65,  0x73,  0x74,  0x20,  0x6c,  0x69,  0x73,  0x74,
      0x20,  0x65,  0x6e,  0x74,  0x72,  0x79,  0x20,  0x30,  0x3c,  0x2f,
      0x6c,  0x69,  0x3e,  0x0d,  0x0a,  0x20,  0x20,  0x3c,  0x6c,  0x69,
      0x3e,  0x54,  0x68,  0x69,  0x73,  0x20,  0x69,  0x73,  0x20,  0x61,
      0x20,  0x74,  0x65,  0x73,  0x74,  0x20,  0x6c,  0x69,  0x73,  0x74,
      0x20,  0x65,  0x6e,  0x74,  0x72,  0x79,  0x20,  0x31,  0x3c,  0x2f,
      0x6c,  0x69,  0x3e,  0x0d,  0x0a,  0x3c,  0x2f,  0x6f,  0x6c,  0x3e,
      0x0d,  0x0a,  0x3c,  0x2f,  0x62,  0x6f,  0x64,  0x79,  0x3e,  0x0d,
      0x0a,  0x3c,  0x2f,  0x68,  0x74,  0x6d,  0x6c,  0x3e, };
    
    /****** End Of File *************************************************/

     

    Content of test.h

    /*********************************************************************
    *               SEGGER MICROCONTROLLER GmbH & Co. KG                 *
    *       Solutions for real time microcontroller applications         *
    **********************************************************************
    *                                                                    *
    *       (c) 2002 - 2015  SEGGER Microcontroller GmbH & Co. KG        *
    *                                                                    *
    *       www.segger.com     Support: support@segger.com               *
    *                                                                    *
    **********************************************************************
    ----------------------------------------------------------------------
    File    : test.h
    Purpose : Automatically created from test.html using Bin2C.exe
    --------  END-OF-HEADER  ---------------------------------------------
    */
    #ifndef __TEST_H__
    #define __TEST_H__
    
    #define TEST_SIZE 198
    
    extern const unsigned char test_file[198];
    
    #endif
    
    //__TEST_H__
    
    /****** End Of File *************************************************/

    全球总部

    德国: SEGGER Microcontroller GmbH

    地址: Ecolab-Allee 5
    40789 Monheim am Rhein, Germany
    电邮: info@segger.com
    电话: +49-2173-99312-0
    传真: +49-2173-99312-28

    网点分布

    中国:哲戈微系统科技(上海)有限公司

    地址: 中国上海市闵行区秀涟路133号
    大虹桥国际A 栋218室
    邮编201199
    电邮: china@segger.com
    电话: +86-133-619-907-60

    通过ISO 9001认证

    ISO 9001

    30多年的嵌入式行业经验

    First-class embedded software tools since 1992
    • 版本说明
    • 免责声明
    • 隐私策略
    • 沪ICP备2022005181号
    • 沪公网安备 31011202014525号
    © 2025 SEGGER - 版权所有.

    您即将离开 segger.cn 而访问境外网站,是否继续?