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

104
Visualizações
BreakIterator failing on Unicode UCD LineBreakTest

The Unicode consortium provides a LineBreakTest file for verifying that your line breaking code works properly. Using Unicode's own library icu4j, I cannot get the × [0.3] HYPHEN-MINUS (HY) ÷ [999.0] NUMBER SIGN (AL) ÷ [0.3] test case to pass. This works with java's built in library. Per the ucd line break table, there should be a break there as well.

What am I missing here? Should there not be a break where it says? Is this locale dependent, but not specified in the LineBreakTest file?

Here is some kotlin code to reproduce.

val lineInstance = java.text.BreakIterator.getLineInstance()
val lineInstanceIcu4j = com.ibm.icu.text.BreakIterator.getLineInstance()

fun main() {
    println(lineBreakJava("-#"))
    println(lineBreakIcu4j("-#"))
}

fun lineBreakJava(text: String): MutableList<String> {
    lineInstance.setText(text)
    var start = lineInstance.first()
    var end = lineInstance.next()
    val breakableLocations = mutableListOf<String>()
    while (end != BreakIterator.DONE) {
        val substring = text.substring(start, end)
        breakableLocations.add(substring)
        start = end
        end = lineInstance.next()
    }
    return breakableLocations
}

fun lineBreakIcu4j(text: String): MutableList<String> {
    lineInstanceIcu4j.setText(text)
    var start = lineInstanceIcu4j.first()
    var end = lineInstanceIcu4j.next()
    val breakableLocations = mutableListOf<String>()
    while (end != BreakIterator.DONE) {
        val substring = text.substring(start, end)
        breakableLocations.add(substring)
        start = end
        end = lineInstanceIcu4j.next()
    }
    return breakableLocations
}

actual output:

[-, #]
[-#]

expected output:

[-, #]
[-, #]

edit:

Apparently IntelliJ had removed my icu4j dependency. After adding it back in I get the reverse of what was happening before. Now test cases that were passing are failing. I've updated the example with one of the failing cases.

over 4 years ago · Santiago Trujillo
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