Skip to content
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

Question regardin find_first_of #18

Closed
shawnim opened this issue Sep 14, 2018 · 2 comments
Closed

Question regardin find_first_of #18

shawnim opened this issue Sep 14, 2018 · 2 comments
Labels
help wanted question solution Issues that end up being of potential help to others.

Comments

@shawnim
Copy link

shawnim commented Sep 14, 2018

First of all, thanks for this great library!
This is not a bug but rather my own user error that I am hoping you can clarify.
I'm trying to call find_first_of passing a utf8_string as the first parameter.
This generates the following error:
error: no matching function for call to ‘utf8_string::find_first_of(utf8_string&, int&)’
int found_pos = haystack.find_first_of(needle, at_pos);
^
In file included from Phonemizer.cpp:8:0:
tinyutf8.h:1728:12: note: candidate: utf8_string::size_type utf8_string::find_first_of(const value_type*, utf8_string::size_type) const
size_type find_first_of( const value_type* str , size_type start_codepoint = 0 ) const ;
^~~~~~~~~~~~~
tinyutf8.h:1728:12: note: no known conversion for argument 1 from ‘utf8_string’ to ‘const value_type* {aka const char32_t*}’

Can you tell me the correct usage and/or how I can get a char32_t* from my utf8_string?
Thanks!
Shawn

@shawnim
Copy link
Author

shawnim commented Sep 19, 2018

I figured out that I could use find instead of find_first_of. So I'll close this issue.

@shawnim shawnim closed this as completed Sep 19, 2018
@DuffsDevice
Copy link
Owner

Hi Shawn,

Sorry for the late reply. Find_first_of currently expects a literal of type char32_t (as you already figured out). You may get a literal through e.g. "0123456789"U. If you just happen to have a dynamic set of codepoints that you want to use find_first_of with (it seems you do), you can get a char32_t* with utf8_string::to_wide_literal().

Does that help you?

Cheers
Jakob

PS: I might add the overload that you are looking for to the library once I have the time to. What keeps me from doing that at the moment, is that all the find_* functions would need to receive that overload and I don't have an idea yet on how to quickly search for any of the codepoints in an utf8_string without much (heap-)memory overhead. So yeah, I may figure that out...

@DuffsDevice DuffsDevice added help wanted question solution Issues that end up being of potential help to others. labels Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted question solution Issues that end up being of potential help to others.
Projects
None yet
Development

No branches or pull requests

2 participants