Menu

#2 Wrong index returned by String.IndexOf () in ProgsEdict.cs in Linux

v1.0 (example)
closed-fixed
nobody
None
5
2014-11-14
2014-11-06
Miguel G L
No

For it to work on Linux (Ubuntu 14.10 64bit | .net mono v3.2.8) I had to add the following code [file: ProgsEdict.cs Class: Progs Method: StringOffset()]

int offset = _Strings.IndexOf(tmp); // todo: optimize this

if (Environment.OSVersion.Platform == PlatformID.Unix || // new code
Environment.OSVersion.Platform == PlatformID.Unix) // new code
offset -= 1; // new code

For example, in linux "String.IndexOf()" method returns an index "offset = 6633" in the case of Windows "offset = 6632". The correct value is 6632

Greetings, thanks for your work ...

Discussion

  • Yuriy Kiselev

    Yuriy Kiselev - 2014-11-13

    Hi Miguel,

    Maybe it is due to '\0' character prepended. Can you also check if overloaded IndexOf(string,StringComparison.Ordinal) works?

    Btw, I almost forgot C# since from 2013 I'm java developer.

     
  • Miguel G L

    Miguel G L - 2014-11-13

    Yeeesss! Modification work. Sorry to let you to program in C#.

    regards

     
  • Yuriy Kiselev

    Yuriy Kiselev - 2014-11-14

    Fixed in r4

     
  • Yuriy Kiselev

    Yuriy Kiselev - 2014-11-14
    • status: open --> closed-fixed
     

Log in to post a comment.