Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda