Allan Wang

06/22/2019, 6:47 AM
I recently had a look at ansi, and I saw libraries like jansi. They use escape codes such as
in java. However, it doesn’t seem to be a valid string in kotlin. Using the library also doesn’t seem to work for me, whereas if I replace
, everything works fine. Is there a reason for this, or a reason why the library doesn’t work when it is used?


06/22/2019, 12:47 PM
Kotlin does not have octal escapes like java does.

Allan Wang

06/22/2019, 6:23 PM
So any java library that uses octal escapes also isn’t supported?


06/23/2019, 5:26 AM
No, octal escapes are compiled into their character representations when the library is built. So when using a Java library, Kotlin would see the character representation (which Kotlin can understand just fine) instead of the octal escape.

Allan Wang

06/23/2019, 7:33 PM
Thanks. I have no idea what happened but now everything works.

Ryan Mentley

06/24/2019, 6:24 PM
The degree to which Java compiles the escapes into characters can be surprising, too...
$ cat && echo -e "\n" && javac && javap Test.class

Compiled from ""
public class Test {
  public Test();

Allan Wang

06/24/2019, 6:37 PM
Looking back I realized there was something wrong with the library. They have an install and uninstall function that checks for ascii support and I guess they detected the wrong setting and used another format. Using system out worked as is