47 lines
1.6 KiB
Text
47 lines
1.6 KiB
Text
include "NSLog.incl"
|
|
local fn snake_toCamel( s as CFStringRef ) as CFStringRef
|
|
long r,f
|
|
s = fn StringByTrimmingCharactersInSet( s, fn CFCharacterSetGetPredefined(_kCFCharacterSetWhitespace ))
|
|
for r = 1 to len(s)-2
|
|
f = instr(0, @"_- ", mid(s, r, 1))
|
|
if f <> NSNotFound
|
|
s = fn stringwithformat(@"%@%@%@", left( s, r ), ucase(mid(s,r+1,1)), mid(s,r+2))
|
|
end if
|
|
next
|
|
end fn = s
|
|
|
|
local fn CamelTo_snake( s as CFStringRef ) as CFStringRef
|
|
long r,f
|
|
s = fn StringByTrimmingCharactersInSet( s, fn CFCharacterSetGetPredefined(_kCFCharacterSetWhitespace ))
|
|
s = fn StringByReplacingOccurrencesOfString( s, @" ", @"_")
|
|
s = fn StringByReplacingOccurrencesOfString( s, @"-", @"_")
|
|
for r = 1 to len(s)-2
|
|
f = instr(0, @"ABCDEFGHIJKLMNOPQRSTUVWXYZ", mid(s, r, 1))
|
|
if f <> NSNotFound
|
|
if fn StringIsEqual(@"_", mid(s, r-1, 1)) then continue
|
|
s = fn stringwithformat(@"%@%@%@", left( s, r ), @"_", mid(s,r))
|
|
end if
|
|
next
|
|
s = fn stringwithformat(@"%@%@",left( s, 1), lcase(mid(s, 1)))
|
|
end fn = s
|
|
|
|
local fn show( s1 as CFStringRef )
|
|
CFStringRef s = @" "
|
|
CFStringRef s2 = fn snake_toCamel( s1 )
|
|
CFStringRef s3 = fn CamelTo_snake( s1 )
|
|
nslog(@" \"%@\"%@\"%@\"%@\"%@\"", s1, mid(s, len(s1)), s2, mid(s, len(s2)), s3)
|
|
end fn
|
|
|
|
nslog( @"%@",@"String ¬
|
|
fn snake_toCamel ¬
|
|
fn CamelTo_snake")
|
|
fn show(@"snakeCase")
|
|
fn show(@"snake_case")
|
|
fn show(@"variable_10_case")
|
|
fn show(@"variable10Case")
|
|
fn show(@"ɛrgo rE tHis")
|
|
fn show(@"hurry-up-joe!")
|
|
fn show(@"c://my-docs/happy_Flag-Day/12.doc")
|
|
fn show(@" spaces ")
|
|
|
|
handleevents
|