Author Topic: pos not working in v20.0.0.12 64-bit  (Read 1244 times)

Bamsen

  • Community Member
  • Posts: 54
  • Hero Points: 8
pos not working in v20.0.0.12 64-bit
« on: November 17, 2015, 02:34:33 pm »
Code:
Code: [Select]
  int i;
  i=pos('[\x80-\xFF]',"This is an Å in position 11.",1,"LI");
  insert_line("i=" i);
Result:
Code: [Select]
i=0

When i use the same expression in Search it works.
When i use the same expression in Regex Evaluator it works.
Code: [Select]
<Regex TypeCode="L">
<Expression>
<![CDATA[[\x80-\xFF]]]>
</Expression>
<TestCase>
<![CDATA[This is an Ã… in position 11.]]>
</TestCase>
</Regex>
It also worked in v19

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 5645
  • Hero Points: 454
Re: pos not working in v20.0.0.12 64-bit
« Reply #1 on: November 17, 2015, 07:46:05 pm »
  /*
  Subtle difference. v19 actually has the bug here. v19 supports matching
  partial Utf-8 characters (1st byte only ) and v20 does not.
   
  I think you meant to do an SBCS/DBCS search. The Regex Evaluator and
  the edit window (I assume you're on Windows) are doing a SBCS/DBCS search
  which is why they work.
   
  By default, all Slick-C compiled strings literals are Utf-8. It's been
  this way for a very long time.
   
  Since on some platforms (Windows), Slick-C files default to SBCS/DBCS and
  others like Mac and Ubuntu it defaults Utf-8, it's a bad idea to use literal characters
  above 127 in a string.
  */
 
  int i;

   // You probably meant to do this. Use the A option for this.
   i=pos('[\x80-\xFF]',"This is an \xc5 in position 11.",1,"ALI");
   say('i='i);
   // This searches a bunch of bytes and can match a byte anywhere in a
   // Utf-8 or DBCS character. Use binary Y option.
   i=pos('[\x80-\xFF]',"This is an \xc5 in position 11.",1,"YLI");
   say('i='i);
« Last Edit: November 17, 2015, 08:41:26 pm by Clark »