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

why is unicode segmentation used? #10

Open
rnag opened this issue Jun 8, 2022 · 2 comments
Open

why is unicode segmentation used? #10

rnag opened this issue Jun 8, 2022 · 2 comments

Comments

@rnag
Copy link

rnag commented Jun 8, 2022

Just curious. Basically, in the context of this line:

heck = { version = "0.4.0", features = ["unicode"] }

I'm not too sure about what the unicode feature is myself, reading up on it in the heck docs now.

Currently i have some test code in rust at least:

assert_eq!("a.b.c".to_snake_case(), "a_b_c");
assert_eq!("a'b'c".to_snake_case(), "a_b_c");
assert_eq!("2this##@$@#$.23432isaTest.Thanks.To.BOB.Myf\"r'e\"'e''nd.".to_snake_case(),
                 "2this_23432isa_test_thanks_to_bob_myf_r_e_e_nd")

this appears to work without the unicode feature, i.e. with heck = "0.4.0", but when I add the unicode feature then the assert stmts seem to fail. I might be wrong, but for valid snake case it might be worth removing the . and the , in the results. Basically, in my use case I want to turn a bunch of words into valid identifier names in python -- so for ex. a_b_c = 2 would work out in my use case, but with special chars it would fail. Is it possible to just have a _ in the returned string?

Side note: also 2this is not a valid identifier in python, but I understand that's not a goal of this library for obvious reasons of course.

@kevinheavey
Copy link
Owner

Hey didn't see this until now!

I'll ask around if there are good ways to publish multiple versions of the library with different features activated in the underlying Rust library

@rnag
Copy link
Author

rnag commented Jul 18, 2022

Awesome, no worries and thanks. Also, just wanted to add I appreciate the great work you are putting into this and with integrating with some cool Rust libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants