Weird sideeffect printing some escape sequence to InelliJ-console, why? - java

If I want to display the simple string "/\" on the IntelliJ-console by doing so:
System.out.println("/\\");
the console produces a hyperlink, which opens my Windows-Explorer if clicked on instead of the above expected output. I tried same code on IDE like Eclipse and NetBeans and it works like expected with no sideeffects. I asked other students working with IntelliJ, and they have the same results.
I solved the problem by appending a non visible white space \u2060 like this:
System.out.println("/\\\u2060");
Now my Question:
Is this a special feature in IntelliJ or some other feature (like regular expression stuff) I don't understand yet?

Related

Swing - Hebrew punctuation (shva) is displayed wrong

I'm trying to localize a Swing application with Hebrew punctuation
But Shva (U+05B0) is displayed wrong, should be displayed as:
System.out.println("\u05D9\u05B0\u05E6\u05B4\u05D9\u05D0\u05B8\u05D4");
Will print correctly the first letter with Shva punctuation:
יְצִיאָה
But when added to Swing application using messages.properties file
It display \u05B0 same as \u05B4 (HIRIQ)
יִצִיאָה
I tried other Unicode option but it didn't work, does anyone have a reason or is there a known limitation ?
It shows the as main menu option it looks OK, as a sub menu (can't enlarger component) it look wrong

Arabic in java error

I'm working currently on java project that uses Arabic Language, I found difficulty in writing in Arabic as shown in the image:
I wrote Arabic without any edit.
I added a reverse() method, it worked good but the letters aren't attached to each other, they're separate.
StringBuilder input = new StringBuilder();
input.append(jTextField2.getText());
input = input.reverse();
jTextField1.setText(input.toString());
I use site the flip the text, it didn't work as well.
I use the same site, but with jLabel it worked.
other method I use, but didn't work:
Try Orientation jTextField1.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
Change the IDE encoding to URT-8 (I'm using Netbeans-JDK8).
Can anyone help me how to write & print Arabic in java correctly?
Please refer to this question -
Forcing RTL order in a JTextArea
Here is a sugestion to start the string with the character \u202e to force the text to be RTL.
Also i think it is not good approach to reverse the string, as it is not good user experience when the user do "copy paste", as he will copy reversed string...
A string entirely composed of characters from the Arabic block should render with correct RTL presentation without any directionality control characters. If it does not, it is likely that you have a problem with your operating system configuration, not with your Java code. Reversing the string is a terrible idea. Trying for visual-order rendering is going to get all messed up.

jsp page auto removes whitespaces

I am writing lots of whitespaces as you can see the code below.
out.println("new Array('1453 12999 ALPER KOPUZ')");
unfortunately when code compiles and run the code in the screen I am able to see it as
"1453 1299 ALPER KOPUZ".
It means it auto removes whitespaces and put only one whitespace after one word.It works fine at older versions of Internet Explorer but it does show line such like "1453 1299 ALPER KOPUZ" at Internet explorer which I need to fix and our application runs on this server.
I tried css "white-space: pre;" but it is still same.
This problem makes me crazy and ate my 3 hours. I would be glad if you have any idea to fix it.
Cheers
Alper Kopuz
I guess using out.println you are writing the text as HTML on your page as response.
You need to have the text pre formatted once you print it as HTML. Try to put your text in pre tag as shown below.
out.println("<pre>new Array('1453 12999 ALPER KOPUZ')</pre>");
Let me know if this is what you were looking for.

Eclipse IDE Scope Highlighting?

When I first learned Java, I was using an IDE called "BlueJ." It had this feature called "Scope Highlighting" which made it very easy to read blocks of code. Now I've moved on from BlueJ and began using Eclipse. I'm currently in the process of customizing Eclipse to my liking and would like this Scope Highlighting feature inside Eclipse.
I've searched everywhere for an answer on how to do it but I cannot find any information pointing to a solution for doing it in Eclipse.
Here's a picture to demonstrate what Scope Highlighting looks like:
I think the best option for you is EditBox, a scope highlighting plugin for Eclipse:
http://editbox.sourceforge.net/
I'm afriad that closest you can get is Shift + Alt + arrow_up
It is selecting wider block of code. pressing this few times will give you very similar result to what you are searching for. I use it often.. it is useful, also for refactoring.
EDIT: As #j2emanue said: you can just double click the delimiter (like a bracket) and it will highlight the entire scope.
you can use Shift + Alt + arrow_up but many people dont realize you can just double click the delimiter (like a bracket) and it will highlight the entire scope. Try double clicking your if statements bracket for example and watch eclipse highlight the entire scope. It works with any delimiter. so you can use parenthesis as well.
as a side note: if your using intelliji checkout this plugin works great: https://github.com/izhangzhihao/intellij-rainbow-brackets#screenshots
This isn't exactly what you're after but you can put your cursor in a method and then click the Show Source Of Selected Element only button on the toolbar. Your editor gets reduced to just that method. Click again and your back to your entire file.
I doubt eclipse does have the same function as blue j.The best advise I can give you, is to change your theme to your liking which would enable you to easily select and highlight the block of code...and to customise your theme , go to http://eclipsecolorthemes.org/. ....
If you still have a problem, go to http://codejava.co.uk/contact.html and send your email.you can create a dummy one if want, then I will send you XML files I use for my eclipse themes.
can Bracketeer do this ? its an eclipse plug in ..
http://marketplace.eclipse.org/content/bracketeer-java-jdt#.UK6sY4fAdLc
Maybe you will also like the VSCode extension "Blockman". It highlights nested code blocks based on curly/square/round brackets, html/xml tags and Python/Yaml indentation. (I am the author of Blockman).
.
https://i.ibb.co/31F0rm9/vscode-blockman-intro-leodevbro-extension3.png
.
.

How to *easily* display Korean characters in a Java program

I'd like to do this:
System.out.println("안녕하세요!");
But I get a "Some characters could not be encoded using the MacRoman character encoding" popup error message when I try to compile in Eclipse. I'm running Mac OS X. Is there a way to get around that?
So, I guess I'll try using Unicode:
System.out.println((char)0xD0A4);
Which I'd like to print out '키', but instead get a '?'. I guess the command line doesn't support Unicode. But even if it did, it'd be really annoying to have to go to one of several charts (like this one) to find each character block.
Anyway, FINE! So I'll use a JLabel...
JLabel lbl = new
JLabel(""+(char)0xD0A4);
Awesome, this prints out 키! ... but I still have to look up the Unicode characters for each block. How can I easily spew out Korean characters in a program?
Switch to UTF-8, as said before.
However, instead of doing it on a per-project basis (as J-16) suggests, go through
Window -> Preferences -> General -> Workspace and change the "Text file encoding" to "Other: UTF-8".
This changes the setting for the entire workspace.
Afterwards, you can input your characters as you are used to.
The Eclipse console doesn't use unicode encoding so it can't display those. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=13865.
Try the fix mentioned here: http://paranoid-engineering.blogspot.com/2008/05/getting-unicode-output-in-eclipse.html
Just right click the file in the project view, choose properties. Change the encoding to UTF8 there.

Categories