DevToys icon indicating copy to clipboard operation
DevToys copied to clipboard

Text Case Convert does not work

Open wima75 opened this issue 3 years ago • 4 comments

Description

The Converters do not work as expected.

Steps To Reproduce

  1. Navigate to Text Case Converter and Inspector
  2. Type FooBar into the textfield
  3. Click the kebab-case button
  4. The result is foobar instead of foo-bar

Expected behavior

foo-bar

DevToys Version

1.0.3.0

Relevant Assets/Logs

2022-02-17 08_22_37-DevToys

wima75 avatar Feb 17 '22 07:02 wima75

Is this really a bug, or just not working the way you assumed...? I don't think the tool should treat all mid-word caps to be in PascalCase. How, for example, should the converter handle these?

  • FOOBAR
  • FooBAR
  • FOOBar
  • FOObar
  • fooBAR

Perhaps there needs to be some selector for the input case where there's ambiguity, but if the tool always treats [\s\-_] as the word separators it is, at least, unambiguous.

jwfxpr avatar Feb 17 '22 08:02 jwfxpr

It would be nice if it would work like here: https://textedit.tools/kebabcase

  • FOOBAR => foobar
  • FooBAR => foo-bar
  • FOOBar => foo-bar
  • FOObar => fo-obar
  • fooBAR => foo-bar

wima75 avatar Feb 17 '22 08:02 wima75

Right, I see.

Perhaps a "Treat capitalization as word boundary" setting is needed that can be toggled on and off, which finds ([a-z\d])([A-Z]) and ([A-Z\d])([A-Z][a-z]) groups.

jwfxpr avatar Feb 17 '22 08:02 jwfxpr

The only case I can think of where a capital letter in the middle of a word is not a word boundary is tHiS cAsE and I don't know what it's called but I don't feel that's something a case converter for devs needs to support. So IMO for all intents and purposes a capital in the middle of the word is always a word boundary.

Edit: The first one only of course, as we can't really say for sure if fooBAR is two, three or four words. Personally I'd go with two words, but that is probably biased.

Regenhardt avatar Mar 23 '22 18:03 Regenhardt