Stats:
-Function Count = 43
-Line Count = 953
-Character Count = 34110
-File Size = 34KB
-Local Functions/Variables(Used by string functions) = 45
Function Listing:
Spoiler
toCharTable(str) –Returns table of @str's charstoByteTable(str) –Returns table of @str's bytes
fromCharTable(chars) –Returns str made of chracters in @chars
fromByteTable(bytes) –Returns str made of bytes in @bytes
contains(str,find) –Returns true if @str contains @find
startsWith(str,Start) –Check if @str starts with @Start
endsWith(str,End) –Check if @str ends with @End
trim(str) –Trim @str of initial/trailing whitespace
firstLetterUpper(str) –Capitilizes first letter of @str
titleCase(str) –Changes @str to title case
isRepetition(str, pat) –Checks if @str is a repetition of @pat
isRepetitionWS(str, pat) –Checks if @str is a repetition of @pat seperated by whitespaces
urlDecode(str) –Url decodes @str
urlEncode(str) –Url encodes @str
isEmailAddress(str) –Checks if @str is a valid email address
chunk(str, size) –Splits @str into chunks of length @size
find(str, match, startIndex) –Finds @match in @str optionally after @startIndex
seperate(str, divider) –Seperates @str on @divider
replace(str, from, to) –Replaces @from to @to in @str
jumble(str) –Jumbles @str
toBase(str, base) –Encodes @str in @base
fromBase(str, base) –Decodes @str from @base
toBinary(str) –Encodes @str in binary
fromBinary(str) –Decodes @str from binary
toOctal(str) –Encodes @str in octal
fromOctal(str) –Decodes @str from octal
toHex(str) –Encodes @str in hex
fromHex(str) –Decodes @str from hex
toBase36(str) –Encodes @str in Base36
fromBase36(str) –Decodes @str from Base36
toBase32(str) –Encodes @str in Base32
fromBase32(str) –Decodes @str from Base32
toBase64(str) –Encodes @str in Base64
fromBase64(str) –Decodes @str from Base64
rot13(str) –Rot13s @str
rot47(str) –Rot47s @str
SHA1(str) –Returns SHA1 Hash of @str
CRC32(str) –Returns CRC32 Hash of @str
FCS16(str) –Returns FCS16 Hash of @str
FCS32(str) –Returns FCS32 Hash of @str
encrypt(str, key) –Encrypts @str with @key
decrypt(str, key) –Decrypts @str with @key
setRandSeed(seed) –Sets random seed to @seed
Example Output:
Spoiler
———-toCharTable("Hello")
1-H
2-e
3-l
4-l
5-o
———-
fromCharTable()
Hello
———-
toByteTable("Hello")
1-72
2-101
3-108
4-108
5-111
———-
fromByteTable()
Hello
———-
contains("Hello", "Hell")
true
———-
startsWith("Hello", "H")
true
———-
endsWith("Hello", "o")
true
———-
trim(" Hello ")
Hello
———-
firstLetterUpper("hello")
Hello
———-
titleCase("hello world, how are you")
Hello World, How Are You
———-
isRepetition("HelloHelloHello", "Hello")
true
———-
isRepetitionWS("Hello Hello Hello", "Hello")
true
———-
urlEncode("Hello There World")
Hello+There+World
———-
urlDecode()
Hello There World
———-
isEmailAddress("cooldude@emailhost.com")
true
———-
chunk("123456789", 3)
1-123
2-456
3-789
———-
find("Hello World HeHe", "World")
7
———-
seperate("1.2.3.4.5", ".")
1-1
2-2
3-3
4-4
5-5
———-
replace("# # # #"," ","*")
#*#*#*#
———-
jumble("Hello World")
oHlord lWel
———-
toBase("Hello", 13)
57:7A:84:84:87
———-
fromBase()
Hello
———-
toBinary("Hello")
1001000:1100101:1101100:1101100:1101111
———-
fromBinary()
Hello
———-
toOctal("Hello")
110:145:154:154:157
———-
fromOctal()
Hello
———-
toHex("Hello")
48:65:6C:6C:6F
———-
fromHex()
Hello
———-
toBase36("Hello")
20:2T:30:30:33
———-
fromBase36()
Hello
———-
toBase32("Hello")
JBSWY3DP
———-
fromBase32()
Hello
———-
toBase64("Hello")
SGVsbG8=
———-
fromBase64()
Hello
———-
rot13("Hello")
Uryyb
———-
rot47("Hello")
w6==@
———-
SHA1("Hello")
f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0
———-
CRC32("Hello")
4157704578
———-
FCS16("Hello")
21548
———-
FCS32("Hello")
3671287311
———-
encrypt("Hello", "Key")
Q4Y3F3X495Z3L476L5Z2G374L4K4L4
———-
decrypt()
Hello
———-
To install:
Spoiler
-Download Zip-place the StrUtils file into mods/ComputerCraft/lua/rom/apis/
-Load up CC
To use:
Spoiler
-Use it just like any other API eg.s,e = StrUtils.find("Hello", "e")
or
digits = StrUtils.seperate("0/65/0", "/")
or
encoded = StrUtils.encrypt("Hello", "CoolKey")
License:
Spoiler
Copyright © 2012 Thomas Farr a.k.a tomass1996 [farr.thomas@gmail.com]Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-Visible credit is given to the original author.
-The software is distributed in a non-profit way.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
If you need clarification on something just ask.
If you find any bugs or errors please report them.
Download:
GitHub
BitBucket
Projects:
GitHub
BitBucket