You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@arcage Thank you, you are totally correct! I applied this optimization recently but it was wrong, I was missing checking that the string is also made of ascii characters.
firejox
pushed a commit
to firejox/crystal
that referenced
this issue
Dec 12, 2016
Hi,
It seem the
Sting#index
andString#rindex
return incorrect results, in case that searches an asciiChar
in the string that includes multibyte letters.My environment:
Code:
When
String#index
orString#rindex
is called with thesearch
argument that is an ascii Char, it delegates the process to#to_slice
.But, index of string is not equal with it of
string.to_slice
when that string includes multibyte letters.This causes the incorrect results of
File.basename
andFile.extname
.Those methods are calling
String#rindex
with'.'
orFile::SEPARETOR
(/
or'\\'
).The text was updated successfully, but these errors were encountered: