Skip to content

String.StartsWith/EndsWith/IndexOf/LastIndexOf ignoring null characters on Unix #4673

Closed

Description

@stephentoub

For example, this:

Console.WriteLine("abcte\0\0\0\0\0st".EndsWith("test"));

prints out true.

Activity

  1. AlexGhiondea commented on Feb 2, 2017

    @AlexGhiondea
    Contributor

    @tarekgh would you mind taking a look at this?

  2. tarekgh commented on Feb 2, 2017

    @tarekgh
    Member

    I believe this is by design in Linux as Linux ignore the null characters. i.e. null characters has no weights for the string comparison. if someone want to to have accurate result should use ordinal comparisons and not linguistic comparison. I understand this is different than Windows but we already have some differences between Windows and Linux in this space.

  3. removed their assignment
    on Feb 2, 2017
  4. AlexGhiondea commented on Feb 2, 2017

    @AlexGhiondea
    Contributor

    Closing per @tarekgh's comments

  5. KristinXie1 commented on Feb 24, 2017

    @KristinXie1

    Disabled test, reopen it.

  6. tarekgh commented on Feb 27, 2017

    @tarekgh
    Member

    @AlexGhiondea I have marked this as a test issue and moved it to the future. please change it back if you think otherwise.

  7. GrabYourPitchforks commented on Jan 29, 2020

    @GrabYourPitchforks
    Member

    @tarekgh Can this be closed? I confirmed that the null character is a weightless character in ICU.

    auto status = UErrorCode{};
    UCollator* collator = ucol_open("", &status);
    
    uint8_t sortKey[64];
    auto result = ucol_getSortKey(
    	collator,
    	(UChar*)L"ab\0cd",
    	5,
    	sortKey,
    	sizeof(sortKey));
    
    result = ucol_getSortKey(
    	collator,
    	(UChar*)L"abcd",
    	4,
    	sortKey,
    	sizeof(sortKey));

    The two calls above will return the same value for result and will both populate sortKey with the same data. This indicates that per ICU the strings "ab\0cd" and "abcd" are equal.

  8. tarekgh commented on Jan 29, 2020

    @tarekgh
    Member

    @GrabYourPitchforks I am closing it. I assume there is no test failing because of that today.

  9. transferred this issue fromdotnet/coreclron Jan 30, 2020
  10. added this to the Future milestone on Jan 30, 2020
  11. safern commented on Feb 15, 2020

    @safern
    Member

    There are still some tests disabled against this issue (with coreclr URL).

    [ActiveIssue("https://github.com/dotnet/coreclr/issues/2051", TestPlatforms.AnyUnix)]

  12. reopened this on Feb 15, 2020
  13. added
    untriaged
    on Feb 26, 2020
  14. ghost locked as resolved and limited conversation to collaborators on Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.Globalizationdisabled-testos-linuxtest-buguntriaged

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions