Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

432
Visualizações
Why in Intellij IDEA presence of ENQ/ESA unicode character in code cause it to show false multiple character literals error?

I was trying to fix some weird PDF Unicode remapping issues when I was stuck by this issue where adding an ENQ Unicode character to some part of the code prevents you from compiling the code and IDE will present you with what I think is a false alarm(error).

Consider this example of completely valid Kotlin code and let's call it Program A where unfortunately you can't see the actual characters here between apostrophes but believe me there's a character in there (if you copy this code into your IDE you can see those characters).

package yamin

fun main() {
    val foo = mutableListOf('')
    //val bar = mutableListOf('')
    println(foo)
}

However, you can see them in the picture.

Program A

But if you decide to compile this code somehow IDE fails to compile it and claims that there are 'Too many characters in a character literal' in line 4.

Program A false error

What is interesting is that the sheer presence of ENQ character even in a comment line prevents the IDE to compile this code and if you remove line 5, therefore, removing the presence of ENQ character then you can compile this code (let's call it Program B), observe:

Program B

Anyway if you decide to remove line 4 in Program A and uncomment line 5 then you can compile that code too (let's call it Program C).

enter image description here

So let's recap Program A is invalid and line 4 is the culprit of the invalidity but removing line 5 in that program which leaves us with Program B could be compiled successfully and this situation is repeated for Program C.

What am I missing here?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It looks like a bug in Kotlin compiler, because the error happens even if the code is compiled with command-line: kotlinc enq.kt -include-runtime -d enq.jar

Also, this simple program gives different results on the playground (correct):

enter image description here

and locally (incorrect):

enter image description here

As a workaround you may use Unicode escape sequence syntax (at least for ENQ symbol):

enter image description here

Playground does the same thing when passing this code to the server, so the compiler gets sanitized code: enter image description here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda