ElliottV4
ElliottV4

Reputation: 51

How do I use custom characters in a java string?

I'm trying to encrypt files in java using random characters. I have created these characters using the private character editor app in windows 10.

However, when I replace letters in a string with these custom characters, the letters are replaced with "?" instead of the desired character.

How can I make it so the letters will be replaced with the desired characters?

Thanks!

EDIT: Here's a screenshot of the character.

enter image description here

String text;
                
    while ((text = br.readLine()) != null) {
        System.out.println(text.replace("a", ""));
    }
                
    br.close();

Upvotes: 0

Views: 575

Answers (1)

Joni
Joni

Reputation: 111219

The first problem you have is that you are trying to write this text to the console with System.out.print. Console output is fairly limited for a number of reasons, most of all because the console UI is not drawn by your program, so you have limited control over it. You need to create a graphical user interface if you want to display these characters.

The simplest GUI there is, is showing a message dialog:

String text = "";
JOptionPane.showMessageDialog(null, text);

The second problem is, that the GUI has to use the custom font you create with the private character editor app. That's how this "character editor" works: it creates a custom font, which is then used by other Windows applications. After some digging, I've found that the editor saves the custom font as a TTE file which is a file format I've never heard of before. There is a standard Java API to load custom fonts but I'm not sure if it will support the files created by the "private character editor".

If you're serious about creating custom fonts, you may want to switch to using more standard font editing software such as FontForge.

Upvotes: 1

Related Questions