Human Readable Strings

Human Readable Strings

Dale.Bartlett
Collaborator Collaborator
505 Views
1 Reply
Message 1 of 2

Human Readable Strings

Dale.Bartlett
Collaborator
Collaborator

I stumbled upon this gem when researching a method to reverse PascalCasing to a sentence string. I trust someone finds it as helpful as I did.

https://github.com/Humanizr/Humanizer

 

Credit for the following answer goes to:

Banketeshvar Narayan

https://stackoverflow.com/questions/323314/best-way-to-convert-pascal-case-to-a-sentence

 

Humanizer is a Portable Class Library that meets all your .NET needs for manipulating and displaying strings, enums, dates, times, timespans, numbers and quantities.

"PascalCaseInputStringIsTurnedIntoSentence".Humanize() => "Pascal case input string is turned into sentence"

"Underscored_input_string_is_turned_into_sentence".Humanize() => "Underscored input string is turned into sentence"

"Can_return_title_Case".Humanize(LetterCasing.Title) => "Can Return Title Case"

"CanReturnLowerCase".Humanize(LetterCasing.LowerCase) => "can return lower case"

Complete code :

using Humanizer;

using static System.Console;

namespace HumanizerConsoleApp

{

   class Program

   {

       static void Main(string[] args)

       {

           WriteLine("AwaitingFeedback".Humanize());

          WriteLine("PascalCaseInputStringIsTurnedIntoSentence".Humanize());

           WriteLine("Underscored_input_string_is_turned_into_sentence".Humanize());

           WriteLine("Can_return_title_Case".Humanize(LetterCasing.Title));

           WriteLine("CanReturnLowerCase".Humanize(LetterCasing.LowerCase));

       }

   }

}

Output

Awaiting feedback

Pascal case input string is turned into sentence

Underscored input string is turned into sentence Can Return Title Case

can return lower case




______________
Yes, I'm Satoshi.
0 Likes
Accepted solutions (1)
506 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Dale,

 

Thank you very much for your useful link.

 

Reading the documentation, I must agree:

 

Wow, Humanizer sure is a really powerful and comprehensive package!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes