Kind of a strange question but... here it goes.
Recently my application threw an IOException that the text only had a clubs symbol in it (like the suit in cards) I know this is probably because there was a number in there that was cast to a char and printed to the screen, and I've found where that might have happened. The only problem is, I can't recreate it in eclipse because the eclipse console doesn't want to print those characters for me. All I get are boxes.
I figure this is an encoding issue or something but I need eclipse to print out those characters just like the windows console would. Is there a setting I can change to do this?
The respective Unicode character is U+2663. Just print "\u2663" and you should be fine. This has nothing to do with ASCII, though.
If you get boxes it may also be a font issue. If the font you selected for the console view in Eclipse does not have a glyph for that code point you'll get boxes, usually. The character might still correctly printed, though. Usually monospaced fonts have that character, though, since it was historically part of the glyphs for the control characters below character code 32 (not that control characters ever had the intention of a visual appearance, but well, they could be in the screen buffer, so someone thought it would be a good idea to display them as well).
Related
I'm developing a java project with eclipse v2021-3, with the software processing v3.5.4, and I want to put unicode characters as a text on my screen.
I can do that and have positive results with no problem, just by doing this:
#Override
public void mousePressed(PApplet p) {
p.text("\u2196", 10, 10); // "\u2196" code for arrow top-left
}
But whenever I try to change the textSize:
p.textSize(10);
It turns all the unicode characters into squares, despite the size I choose.
https://prnt.sc/12pykgs -> this is a screenshot of before and after I scale the text.
In my work colleague is also working with eclipse and processing in her computer and she can do this without any problems, and I've looked for help on the forums and I haven't found anything.
Thank you in advance if you can help me with this problem! :)
Host OS configuration problem, not a programming problem
Likely not a Java programming problem, nor a problem with Eclipse. Likely a problem related to font problems on your particular computer.
See similar code run live on IdeOne.com.
String input = "\u2196" ;
System.out.println( input ) ;
↖
Code point U+2196 in hex (8,598 decimal) is NORTH WEST ARROW.
You should be seeing this character if your display app is running on a computer offering a font with a defined glyph. If none of the available fonts has such a glyph, you will get a fall-back glyph such as empty box.
Im trying to put text with arabic letters, some of the text working correctly, and the others symbol is showing weirdly.
Some of the letters just font issue, i can still tolerate if it fix all the mistakenly displayed symbol.
I tried to change font, putting on string, custom font, but it does not work. Any ideas guys ?
i put the pull the text from string res currently.
here is the wrong letters.
here is the correct letters
You should use custom font for your view..
For example this view support TextView custom font from assets.
If you were wondering what encoding would be most efficient:
All Arabic characters can be encoded using a single UTF-16 code unit (2 bytes), but they may take either 2 or 3 UTF-8 code units (1 byte each), so if you were just encoding Arabic, UTF-16 would be a more space efficient option.
Is there a way to adjust the spacing between new lines when outputting to the console through System.out.println? I'm attempting to print out a square with a basic nested for-loop, but I keep getting a rectangle despite having the right number of characters. This is because the spacing between the characters is different than the spacing between lines. Any ideas?
The standard output stream is just a stream of data; how that data is displayed is up to the application displaying it (e.g. a terminal or your IDE). You'll either have to settle for a rectangle, or find a different method of output than standard out.
Without your current code, it's hard to say exactly whats going on. My first thought is, make sure you're using a character that is as high as it is wide, e.g. *.
Second thought is (and again, I have no code to reference), see if you get the same result using one of the algorithms here: Printing a Square with loops, perhaps there is an issue with the square-printing logic that you overlooked.
I'm trying to use the text component of JavaFX to do some nice headline typography in my application. How ever the letters in the text are not spaced evenly. For example in the word "visiting", the "iting" part seems disconnected from the first part.
In the sample image I'm using Arial but this kind of bad spacing happens with every font I tried.
This only happens when "gray" anti-aliasing is used (-fx-font-smoothing-type: gray;). One obvious solution would be to change -fx-font-smoothing-type to lcd, but that would result in the text having jagged edges.
The only thing remotely mentioning something like this is the jira issue RT-14187, but that seem to have been resolved in javafx 8 (jre 8).
I want to write a java program to print Unicode characters. I want to detect and not print Unknown/Unassigned CHaracters (which are shown by a rectangular). I have tried "isDefined" and "isISOControl" from "Character" class, but it does not work.
Does anybody know the solution? it will be a big help for me.
Thanks.
The characters that are shown as a rectangle (on Windows) are ones that aren't available in the font you're using. While you could filter out a lot of them by filtering out undefined and control characters, it's entirely possible that the problem you're running into is that your font doesn't support certain ranges of valid characters (which is typical -- very few fonts define glyphs for all defined Unicode characters).
If your goal is really to remove characters that render as a rectangle, you can use the canDisplay method in Font.