text2binary

Crates.iotext2binary
lib.rstext2binary
version1.0.1
created_at2025-07-18 22:43:19.368225+00
updated_at2025-07-18 23:09:36.66101+00
descriptionConverts a string representation of a hexadecimal number to a Vec
homepage
repositoryhttps://github.com/nogino-sanebou/text2binary
max_upload_size
id1759758
size14,991
nogino sanebou (nogino-sanebou)

documentation

README

Overview

Converts a string representation of a hexadecimal number to a Vec<u8>.

Supported are String, Vec<String> and Files.

The string can include spaces and line breaks.

Case insensitive.

Errors

It was not a hexadecimal representation.

Example

String pattern

let text: String = "001234Ab".to_string();
let binary: Vec<u8> = text2binary::convert(&text).unwrap();

// [0x00, 0x12, 0x34, 0xAB]

let text: String = r#"00 12
34 56"#.to_string();
let binary: Vec<u8> = text2binary::convert(&text).unwrap();

// [0x00, 0x12, 0x34, 0x56]

Vec<String> pattern

let lines: Vec<String> = vec!["1234".to_string(), r#"AB
cd"#.to_string(), "".to_string(), "00 00".to_string()];
let binary: Vec<u8> = text2binary::convert_line(&lines).unwrap();

// [0x12, 0x34, 0xAB, 0xCD, 0x00, 0x00]

File pattern

use std::fs::File;

// target.txt
// 00 12 34
// 56 78 AB
// cd Ef 00
let file: File = File::open("target.txt").unwrap();
let binary: Vec<u8> = text2binary::convert_file(&file).unwrap();

// [0x00, 0x12, 0x34, 0x56, 0x78, 0xAB, 0xCD, 0xEF, 0x00]
// target.txt
// cd Ef 00
//
// 56 78 AB
//
// 00 12 34
//
//
let file: File = File::open("target.txt").unwrap();
let binary: Vec<u8> = text2binary::convert_file(&file).unwrap();

// [0xCD, 0xEF, 0x00, 0x56, 0x78, 0xAB, 0x00, 0x12, 0x34]

日本語概要

16進数の文字列表現をバイナリデータ(Vec)に変換します。

String、Vec<String>、Fileに対応しています。

文字列には空白、改行コードも含められます。

大文字と小文字を区別しません。

エラー

16進数表現ではなかった。

Commit count: 0

cargo fmt