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

310
Visualizações
What is a single pipe equivalent in dart?

I'm attempting to convert a piece of PHP code to dart and I came across a few things I've simply never used before, one of which is a single pipe |. Im not sure what the exact dart equivalent is, if there even is one.

The piece of code in PHP I'm attempting to convert is:

$cc1 = (chr(ord($c1) / 64) | "\xc0");

What I've got so far converted into dart is:

var cc1 = (String.fromCharCode(c1.codeUnitAt(0) / 64) | "\xc0");

However, the single pipe | is giving me a dart error The operator '|' isn't defined for the type 'String'., but as far as I can tell, the php chr should be giving a string as its output, so it brings up the question of if single pipe is actually doing the same thing in dart as it does in PHP?

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

0

The operation is bitwise-OR, and the equivalent operator is |. However, PHP is lenient about types, and Dart is type-safe. It will not convert strings to integers for you. You can do:

var cc1 = c1.codeUnitAt(0) | 0xc0;

cc1 will be an int. If, say, you want it to be a String with the hexadecimal representation, you can do:

var cc1 = (c1.codeUnitAt(0) | 0xc0).toRadixString(16);
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