Fundamentals 4 min read

Decoding Binary UTF-8 Signage in a Public Restroom Using Java

The article explains how a binary message on a multilingual public‑restroom sign was decoded by identifying UTF‑8 byte patterns, extracting the first 24 bits to reveal the Chinese character “向”, and providing a Java program that parses the entire bit string into readable Chinese text.

Java Tech Enthusiast
Java Tech Enthusiast
Java Tech Enthusiast
Decoding Binary UTF-8 Signage in a Public Restroom Using Java

The article describes a binary message found on a public restroom sign written in Chinese, English, Japanese and Korean, and explains how the binary part likely represents UTF‑8 encoded Chinese characters.

It reviews UTF‑8 encoding principles, including byte patterns for 1‑4 byte characters, and shows how to identify the leading bits to determine character length.

By extracting the first 24 bits (starting with 1110) and removing the marker bits, the binary sequence 0101 010000 010001 is obtained, which corresponds to the Unicode code point 0x5411, the character “向”.

To automate the conversion of the full binary string, a Java program is provided that parses the bit string into bytes and prints the resulting Chinese text.

private static void toChinese() {
    String bits = "11100101100100001001000111100101100010011000110"
            + "1111001001011100010000000111001011011000010001111111001"
            + "10101011011010010100100000111001101001011010000111111001"
            + "10100110001000111011100100101110001000000011100101101001"
            + "0010100111111001101010110110100101";
    int length = bits.length();
    byte[] bytes = new byte[length >> 3];
    for (int i = 0; i < length; i += 8) {
        String byteString = bits.substring(i, i + 8);
        bytes[i >> 3] = (byte) Integer.parseInt(byteString, 2);
    }
    System.out.println("转换之后的结果:" + new String(bytes));
}
JavaUnicodeUTF-8Binary Encodingcharacter encoding
Java Tech Enthusiast
Written by

Java Tech Enthusiast

Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.