Hongmu Notes

🗄️ Convert string to binary

Enter a piece of text and get a binary string of 8 bits each.

Convert string to binary

Instructions for use

  • Encoded according to UTF-8: 1 byte for English numbers, 3 bytes for Chinese characters, 4 bytes for emoticons
  • Output a continuous 8-digit fixed-length string, which can be restored by pasting it back into "Binary to String"
  • All is done locally in the browser, and the input content will not be uploaded.

String to byte binary

When writing to a message or database field, "how many bytes does this text have?" is often more important than the binary itself. The tool directly displays the number of bytes and digits, eliminating the need for additional calculations.

📌 What does the status line give?

After the conversion, a prompt will appear saying "N bytes, total M bits have been converted to binary", where M must be equal to N times 8, which can be used to cross-verify whether the result length is as expected.

⚙️ Actual measurement sample

inputNumber of bytesNumber of digits
A18
Hi216
in324
Chinese abc1080

🧭 What to do if the lengths don’t match

If the number of bytes is more than expected, the common cause is that there are extra spaces or newlines at the end of the sentence; just delete them and convert again. Dividing the number of digits by 8 can also quickly locate whether invisible characters are clipped.

📌 Why Bytes Matter

Many protocol fields declare their length in bytes. Wrong input of one byte will cause parsing failure. After conversion, first check the number of bytes in the status line and compare it with the protocol declaration to avoid most length problems.

📌 Number of bytes versus character width

English numbers are 1 byte, commonly used Chinese characters are 3 bytes, and expressions are 4 bytes. Knowing the number of various characters in the text, you can estimate the total number of bytes and confirm it with the status line prompts to quickly determine whether the input is consistent with expectations.

All keywords and tutorials 12

❓ FAQ

Is the number of bytes the same as the number of characters?
It’s the same when it’s pure English, but it has more bytes when it contains Chinese or emoticons. The status line gives the number of bytes, and the number of characters can be viewed separately with the text statistics tool.
Can the results be directly used for interface debugging?
Yes. It is a standard byte sequence representation and can be converted as needed before being pasted into the hexadecimal or binary field of the debugging tool.
How to confirm that the result is correct?
Copy the result to the "Binary to String" tool and restore it. If the original text can be restored, it means it is correct; you can also check whether the number of bytes and digits in the status line are as expected.