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

UTF-8 string conversion methods #194

Open
paulocoutinhox opened this issue Sep 11, 2023 · 2 comments
Open

UTF-8 string conversion methods #194

paulocoutinhox opened this issue Sep 11, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@paulocoutinhox
Copy link

Hi,

I want suggest to add string convertion methods, example:
https://github.com/xplpc/xplpc/blob/main/jni/lib/src/xplpc/jni/support.cpp

Since this library will solve JNI problems, why not methods to work with String convertions :)

Thanks.

@jwhpryor
Copy link
Collaborator

Ok, you're specifically referring to UTF8 correct?

If so, could you update the bug title to reflect that? I assume you're aware that there are already string conversions for existing char*, std::string etc.

@paulocoutinhox paulocoutinhox changed the title String convertion methods UTF-8 String convertion methods Sep 13, 2023
@paulocoutinhox paulocoutinhox changed the title UTF-8 String convertion methods UTF-8 string convertion methods Sep 13, 2023
@jwhpryor jwhpryor added this to the Release 1.1 milestone Jan 5, 2024
@jwhpryor jwhpryor changed the title UTF-8 string convertion methods UTF-8 string conversion methods Mar 16, 2024
@jwhpryor jwhpryor self-assigned this Mar 16, 2024
@jwhpryor jwhpryor added the bug Something isn't working label Mar 18, 2024
@jwhpryor
Copy link
Collaborator

So, I took a pass through your conversion code, and had a chance to think a bit on this myself.

I think your conversion may be simple a subset of the behaviour LocalString already supports.

The former case is a function that takes in a std::string and performs a conversion to UTF16 from UTF8. I believe just using a regular ctor is equivalent?

The latter converts from a UTF16 string to a regular std::string, however, LocalString just directly asks for a UTF8 string, so you're probably just making your conversion explicit, or making an unnecessary one (I don't know what the JVM does internally).

That said, in C++20, UTF16 has its own view std::filesystem::path::u16string. Here, calling GetUtfString could actually be efficiently represented. So, I think this should be revisited when C++20 support is added, but I think your conversion methods are already covered.

@jwhpryor jwhpryor modified the milestones: Release 1.1, Release 2.0 Mar 18, 2024
@jwhpryor jwhpryor added enhancement New feature or request and removed bug Something isn't working labels Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants