# New Ticket Created by  "Clinton A. Pierce" 
# Please include the string:  [perl #22718]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22718 >


In this code:

.sub _main
         .local string source
         .local string lookfor

         source="This is not quite right"
         lookfor=" is "

         index $I0, source, lookfor, 0
         print "(expect 4) $I0 = "
         print $I0                      # you'll actually get -1

         lookfor="is"
         index $I0, source, lookfor, 0
         print "\n(expect 2) $I0 = "
         print $I0                      # You will correctly get 2
         end
.end

The string " is " (note the spaces) will not be found within "This is not 
quite right".  Removing the spaces has the expected results.  I looked 
briefly for an explanation in strings.c but my eyes glazed over at the 
sight of the multibyte and encoding stuff.  




Reply via email to