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

247
Views
Need understanding as to why string.StartsWith() is true when it should be false

So I have this file that I download via ftp. The file is just a config file for a system at my company I work for. Once the file is downloaded I open the file and processor the file. Part of the processing of the file is to check to see if a line starts with a Unicode character \u001a.

This is where I am stumped because .StartsWith("\u001a") is always true, yet I cannot see why. If I view the file in Notepad++ or in a hex editor, I just don't see that.

So there is something I am missing here.

Here's a minimal example (fiddle):

// prints True in .NET 5
Console.WriteLine("Hello".StartsWith("\u001a"));
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's because a breaking change in the globalizations APIs in .NET 5. You can choose one of the following approaches

  1. Use StringComparison.Ordinal or OrdinalIgnoreCase
  2. Use NLS instead of ICU, with one of the following ways:
  • In the project file:
<ItemGroup>
  <RuntimeHostConfigurationOption Include="System.Globalization.UseNls" Value="true" />
</ItemGroup>
  • In the runtimeconfig.json file:
{
  "runtimeOptions": {
     "configProperties": {
       "System.Globalization.UseNls": true
      }
  }
}
  • By setting the environment variable DOTNET_SYSTEM_GLOBALIZATION_USENLS to the value true or 1.
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!