use isempty(String) instead of length(String)<1

general definition of ucfirst/lcfirst also works for UTF8