-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Output rfind() #175
Comments
bstr the library universally operates in terms of byte offsets. if you'd like to count in terms of characters, use one of the iterators like let haystack_str = BStr::new("日本語テキストです。0123456789。E");
let pos = haystack_str.rfind("。").unwrap();
let s = &haystack_str[..pos];
let char_pos = s.chars().count(); |
You need to explain why you expect the output to be 20. Because 50 looks correct. While in not certain, you'll probably want to read this thread carefully: BurntSushi/aho-corasick#72 |
And to be clear here, you almost never want this. Almost never. OP, if you describe the higher level problem you're trying to solve, we can probably guide you in the right direction. |
https://github.com/php/php-src/blob/master/ext/mbstring/tests/mb_strrpos_basic.phpt Please check it
|
I think it is working. :) |
Read the thread I linked. Different environments can return different offsets depending on how the string type is represented. Seriously, read the thread I linked. It should answer everything. |
Thank you |
Output: 50
Expected output: 20
How to fix it?
The text was updated successfully, but these errors were encountered: