I want to print some special characters(Latin, Greek alphabet, Chinese, etc) in Kotlin, but always got ??????? as the output:
>> println("Δ")
>> ??????
Also tried unicode:
>> println("\u0394")
>> ?
IDE I used: IntelliJ IDEA 2018.1.3.
Console I used: Kotlin REPL.
jdk: 9.0.4
Kotlin version: 1.2.31 (JRE 9.0.4+11)
How could I print the right string?
Update(20180512):
I also tried to install Kotlin via Homebrew and run kotlinc in my own terminal, it works as expected. It just doesn't work in Kotlin REPL of IntelliJ. Any place I can go to fix that?
Update(20180513):
Tried the followings:
Clear IntelliJ cache;
Reinstalled IntelliJ;
Make IntelliJ and Kotlin up to date;
Restart MacOS(10.12.6);
Update Java to 10.0.1.
Used println in Kotlin REPL again, ??? changed to the specific error:
println("Δ")
Internal error occurred. Please, send report to developers.
exception: java.nio.charset.MalformedInputException: Input length = 1
at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:281)
at kotlin.io.ConsoleKt.tryDecode(Console.kt:198)
at kotlin.io.ConsoleKt.readLine(Console.kt:162)
at kotlin.io.ConsoleKt.readLine(Console.kt:149)
at org.jetbrains.kotlin.cli.jvm.repl.reader.IdeReplCommandReader.readLine(IdeReplCommandReader.kt:22)
at org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal.one(ReplFromTerminal.kt:98)
at org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal.doRun(ReplFromTerminal.kt:69)
at org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal.access$doRun(ReplFromTerminal.kt:38)
at org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal$Companion.run(ReplFromTerminal.kt:175)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:105)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:63)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:107)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.java:51)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:96)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:72)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:38)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:171)
at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:162)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:329)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
Internal error occurred. Please, send report to developers.
Process finished with exit code 2
It seems the reading character encoding is different from writing encoding. But I can find no way to config the encoding of Kotlin REPL.
And also, I found 2 java processes running while I open Kotlin REPL and every time I have to kill one to run Kotlin REPL smoothly:
image: 2 java processes running
I'm not sure if they are related, so I attached the image as a reference. Already reported to IntelliJ developers, but it seems not a common bug for most people.
Try to run println("\u0394"). If that works, your file likely isn't in the UTF-8 encoding. If it doesn't, there's an issue with your terminal.
Related
When analysing my code using valgrind (WSL) only output I get is list of problems found by it.
On the contrary in Clion documentation in valgrind section, images show that output (instruction pointer) can be directly interpreted into code line that has triggered it, as shown on the image below.
Whan do I need to do to toggle on this display mode or at least code line which triggered it, I am using CLion 2022.2.4?
I have already tried playing with diffrent flags but I was unable to toggle this view on.
This could be related to this bugzilla item (but not likely).
I tried it with CLion 2022.3.1 on FreeBSD 13.1. It was painful to get a project setup (clion didn't know where clangd or ninja were, and used a load of unrecognized clangd options).
After that no real problems.
I'm fairly certain none of the Valgrind devs uses WSL so the chances of this getting analyzed and fixed are very low.
Kotlin Repl does not open ,nothing happens on clicking it
My solution/workaround. What happens is, and by the way the Intellij ide warns you about this, that you create the project and when naming it you use a space or similar unsupported character and the ide still seems to create the project just fine but actually it doesn't. Your project comes out misconfigured and you can't use Kotlin Repl. The simplest solution is to replace any spaces (or similar forbidden characters) with a hyphen "-" or an underscore "_" or simply use cammelCase. Best of luck to everybody and hope future learners of kotlin see this and spend less time troubleshooting such a simple issue.
Do you have a project open when you click it? This post states: "At this time the Kotlin REPL requires you to have a project open. You don't need to configure anything specific in the project; a Java project with the default settings will run just fine.
If you want to try Kotlin without configuring anything, you can use the online IDE at http://try.kotlinlang.org/"
I have used Kotlin with latest version of Eclipse for 2 months without any performance problem on my Windows 10 computer.
Now I would like to do a live coding session about Kotlin with intelliJ (since it's the JetBrains language...) ultimate edition that I just installed and never used before, on a recent OSX computer. The two computers have good hardware and are no limiting my tests.
My problem is that each time there is a modification in my Kotlin code, the compilation time is between 8 seconds and 35 seconds. I did my tests on minimalist code:
class TestKotlin {
var a = 1
}
If I change the variable "a" and so need to build again, it always need 8 seconds in the best cases to complete the compilation.
Since I want to do a live coding session with a lot of small functions and compilations, this kind of delay is way too much significative.
The viewers will need to wait a lot before to see the results at each compilation, they are logically expecting good performance from IntelliJ tool.
In the same project, I tried to do the same kind of Java class (with a single attribute) and modify its attribute in order to trigger the compilation, and it takes less than 1 second to compile.
I tried to manually compile the code in command line with that:
kotlinc hello.kt -include-runtime -d hello.jar
java -jar hello.jar
I had some decent compilation times, even if it was near to 3 seconds.
When I look at the "Messages" screen in IntelliJ while it is compiling Kotlin code, I can see this:
Information:Kotlin: Kotlin JPS plugin version 1.0.6-release-127
Information:Kotlin: Using kotlin-home = /Users/myUsername/Library/Application Support/IntelliJIdea2016.3/Kotlin/kotlinc
It stops here for all the compilation time, and then do almost instantaneously the next steps:
Information:Kotlin: Kotlin Compiler version 1.0.6-release-127
Information:17/01/17 11:38 - Compilation completed successfully in 11s 639ms
Maybe there is a problem in the configuration of IntelliJ or something like this. I had a hard time at searching for something that could improve the performances but nothing helped me...
I would be very grateful if someone can help me to have some realistic compilation time with Kotlin in Intellij like in Eclipse!
This seems similar to the problem KT-15491.
To ensure that it's your case too, try to execute the following simple Kotlin program:
import java.io.File
import kotlin.system.measureNanoTime
fun main(args: Array<String>) {
val elapsedNs = measureNanoTime { File.createTempFile("tmp", "", null).deleteOnExit() }
println(elapsedNs.toDouble() / 1000000000)
}
If the printed elapsed time is significantly greater than a fraction of a second, than that is the reason.
This issue affects not only Kotlin compiler but every JVM program that tries to create a temporary file, or to do any other action involving SecureRandom class.
I've experienced the same slowdown on each JPS build on my Windows 7 notebook. I've tried the workaround with security providers order described in this question and it helped.
Make sure you have checked those boxes in settings:
Incremental Kotlin compilation
Kotlin compiler daemon (keeps the kotlinc process alive)
I just solved a problem which took me way too much time so I thought I share the solution here in case anyone else is biting bricks because of this.
what happened?
I run Pentaho Data Integration 5.2 on CentOS 6.6.
It worked like a charme until I ran yum update the last time.
Now when I was using the graphical interface spoon crashes immediately when I would open an element (e.g. table input) and try to select the query text.
Sometimes it leaves a crash message sometimes not.
Here is the error message:
java: cairo-misc.c:380: _cairo_operator_bounded_by_source: Assertion `NOT_REACHED' failed.
./spoon.sh: line 206: 8922 Aborted (core dumped) "$_PENTAHO_JAVA" $OPT -jar "$STARTUP" -lib $LIBPATH "${1+$#}"
A colleague of mine remembered a quite similar problem he had with his Eclipse and found the solution for me which was to add the following line into spoon.sh into OPT variable:
-Dorg.eclipse.swt.internal.gtk.cairoGraphics=false
It now looks like:
OPT="$OPT $PENTAHO_DI_JAVA_OPTIONS -Djava.library.path=$LIBPATH -DKETTLE_HOME=$KETTLE_HOME -DKETTLE_REPOSITORY=$KETTLE_REPOSITORY -DKETTLE_USER=$KETTLE_USER -DKETTLE_PASSWORD=$KETTLE_PASSWORD -DKETTLE_PLUGIN_PACKAGES=$KETTLE_PLUGIN_PACKAGES -DKETTLE_LOG_SIZE_LIMIT=$KETTLE_LOG_SIZE_LIMIT -DKETTLE_JNDI_ROOT=$KETTLE_JNDI_ROOT -Dorg.eclipse.swt.internal.gtk.cairoGraphics=false"
Now it works again.
Apparently the problem was with the cairo graphics package.
I really love it when stuff doesn't work anymore after updating..
I handed in a C program which contained a lot of verbose printf debug lines. I always compiled it command line with gcc.
Now it's been turned into an Eclipse-CDT (Helios) project, and my
\n
no longer do carriage returns. I get an unreadable "staircase" in my console.
RCINAHFM. Is there a check box in the IDE I need to modify or do I need to go back and carefully modify hundreds of lines of code?
Any help greatly appreciated.
Bert
RCINAHFM=Remaining calm / I need a hug from Mom
Eclipse does not compile C all by itself. It uses an external compiler for that, usually gcc. So it’s highly unlikely that the compiled program is incorrect, unless the compiler configuration within Eclipse does something very, very weird.
If you get a “staircase”, it sounds as if the new line part is carried out, but no carriage return happens. This might happen under systems that use CR/LF as their line ending, such as DOS/Windows.
Unfortunately, you give way to little detail. Are you using Unix or Windows? Where does the program run, in an XTerm, a Windows DOS console, within the Eclipse console? If the answer is “Eclipse console”, then have you tried running it in another terminal instead; or tried running your original program in the Eclipse console? Are you using printf or some other function?