Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

308
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!