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.

UTF-8 to binary

When learning or debugging coding problems, it seems to be the most direct way to match the text with its UTF-8 bytes: which character occupies how many bytes and what is the highest bit, you can match it at a glance.

📌 Manual verification of coding usage

Convert a Chinese character into binary, group it into 8-bit groups, and compare it with the prefix rule: the first byte of the 3-byte UTF-8 sequence starts with 1110, and the last two bytes start with 10. The three groups that are measured as "medium" are exactly 11100100, 10111000, and 10101101.

⚙️ Common uses

  • Check whether the bytes returned by the interface are consistent with the expected encoding
  • Example of organizing fields for an agreement document
  • Verify the root cause of character set-related issues

🧭 Conversion to hexadecimal

There are two hexadecimal digits for every eight binary digits: 11100100 is E4. If you have a coding table on hand, you can convert it first and then compare it without having to re-convert the entire text.

📌 Ideas for troubleshooting coding issues

When garbled characters appear on the page or interface, convert the problematic characters into bytes and check whether they comply with the UTF-8 prefix rules: three bytes begin with 1110 and subsequent characters begin with 10. If it doesn't match, it means it was processed with other codes in the process.

All keywords and tutorials 12

❓ FAQ

Are the English results related to encoding?
Nothing to do. The ASCII range is the same byte in UTF-8 as in other common encodings, so the result for plain English text is consistent everywhere.
Can the results be written directly into the configuration file?
Yes. Continuous 8-digit fixed-length strings are a common byte representation and can be pasted directly; if the target requires hexadecimal, please convert it first according to its requirements.
Will English become longer?
No. ASCII characters are still 1 byte and 8-bit binary under UTF-8. For example, A is 01000001, which is exactly the same as the old writing method.