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

268
Visualizações
String to character array returning different result in Visual Studio and Android Studio

The string that I want to convert into character array is ষ্টোর it is in Unicode and a Bengali word.

The problem is when I am converting it in Visual studio then it is returning 6 characters but when I am converting it in Android Studio then it is showing 5 characters.

In VS I am using char[] arrayOfChars = someString.ToCharArray(); and in Android Studio char[] arrayOfChars = someString.toCharArray();

Visual Studio Debugging info

Android Studio Debugging info

N:B: My Android Studio IDE and Project Encoding is UTF-8. I am expecting same result as Visual Studio in Android Studio.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Those two arrays are unicode equivalent, but are being represented by different normalization forms. What seems to be happening is that the Java ToCharArray (or string representation) is using one normalization form, while the C# ToCharArray (or string representation) is using another.

This page contains a chart of different normalization forms for Bengali text - the fourth row there describes exactly what you're seeing:

Bengali table

I am only learning about this now, but it seems to me that the motivation for this is so that unicode implementations could remain compatible with pre-existing encodings wherever possible and practical.

For example, one pre-existing encoding may have used a single unicode character, while another pre-existing encoding may have instead used two characters combined. The solution settled on by the unicode folks is thus to support both, at the cost of not having a single "canonical" representation, as you've encountered here.

If you wish for your Java array to be normalized under the "D" normalization form that your C# array seems to be using, it appears that this page provides such a function. You may be looking for something like:

someString = Normalizer.normalize(someString, Normalizer.Form.NFD);

Unicode standard annex 15 is the official document that describes these normalization forms.

about 4 years ago · Santiago Trujillo Relatório

0

You must have entered the string differently.

The text ষ্টোর is Unicode code points 09B7 09CD 099F 09CB 09B0, i.e. 2487 2509 2463 2507 2480, as your C# shows.

The values shown by Java, i.e. 2487 2509 2463 2503 2494 2480, has the 4th character 2507 / 09CB as the two characters 2503 2494 / 09C7 09BE.

Looking them up, they are:

ো ↔ 'BENGALI VOWEL SIGN O' (U+09CB)

vs.

ে ↔ 'BENGALI VOWEL SIGN E' (U+09C7)
া ↔ 'BENGALI VOWEL SIGN AA' (U+09BE)

which combined comes out to the same thing:

ষ্টোর ↔ 09B7 09CD 099F 09CB 09B0
ষ্টোর ↔ 09B7 09CD 099F 09C7 09BE 09B0

They are combining characters, and there are different ways to combine characters to get the same result.

about 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