Skip to content

why is unicode segmentation used? #10

@rnag

Description

@rnag

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions