Author Topic: bug : UILabel.GetUrlAtCharacterIndex()  (Read 268 times)

QiuLei

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
bug : UILabel.GetUrlAtCharacterIndex()
« on: October 30, 2017, 03:16:31 AM »
   public string GetUrlAtCharacterIndex (int characterIndex)
   {
      string s = printedText;

      if (characterIndex != -1 && characterIndex < s.Length - 6)
      {
         int linkStart;

         // LastIndexOf() fails if the string happens to begin with the expected text
         if (s[characterIndex] == '[' &&
            s[characterIndex + 1] == 'u' &&
            s[characterIndex + 2] == 'r' &&
            s[characterIndex + 3] == 'l' &&
            s[characterIndex + 4] == '=')
         {
            linkStart = characterIndex;
         }
                        //Awlays return -1 here.
                        //String.LastIndexOf(string value, int startIndex),then second param means "endIndex", not “startIndex”.
                        //Maybe its a C# problem
         else linkStart = s.LastIndexOf("[url=", characterIndex);
         
         if (linkStart == -1) return null;

         ...
      }
      return null;
   }
« Last Edit: October 30, 2017, 03:53:33 AM by QiuLei »