Prototype String Utilities
I created these utilities some time ago for my own projects. They will have gone through numerous versions. I've tried to keep them small, only including operations I find myself doing time after time.
I finally found the time to make proper repros and read me files so I could upload them. I hope you find them as useful as I do!
2.3
As these are Prototypes and not framework functions, all you need to do is load the file as part of your stack. I recommend after your other library includes.
Strips all HTML tags from a string.
( String ).stripHTML();
//<div>testing <strong>the</strong> string</div> => testing the stringEncodes a string in UTF8 format. (mostly needed for the base64 methods, but also has other uses)
( String ).encodeUTF8();Decodes a UTF8 string. (mostly needed for the base64 methods, but also has other uses)
( String ).decodeUTF8();Encodes a string in Base64 format. (mostly needed for the base64 methods, but also has other uses)
( String ).encodeBase64();
//encodeThis => ZW5jb2RlVGhpcw==Decodes a Base64 string. (mostly needed for the base64 methods, but also has other uses)
( String ).decodeBase64();
//ZW5jb2RlVGhpcw== => encodeThisTrims comma separated strings to certain length of properties.
( String ).trimProperties( length );
//I, only, want, to, see, two => I, onlyTrim strings to a certain length and adds an ellipsis if needed. Strings shorter than the length will not be altered.
( String ).trimToEllipsis( length );
//I only want to see five characters => I only...Parse a string as a Boolean value.
( String ).parseBoolean();
//'true' => trueParse a querystring into a JavaScript object.
( String ).parseQueryString();
//this=that&cats=floofs => {this:'that',cats:'floofs'}2.3 Adjusted comments to match read me. Force strict modes. Added more options to parseBoolean. Cleaned up scripts for readability.
2.2 Added trimToEllipsis function.
2.1 Added parseQueryString function.
2.0 Rebuilt script to be prototypes instead of framework functions.
1.0 Added parseBoolean function. Cleaned up methods.
0.5 Added trimProperties function.
0.3 Added stripHTML function.
0.1 Added encodeUTF8, decodeUTF8, encodeBase64 and decodeBase64 functions.
MIT
It's Free!