Returns a capitalized self

Letters that follow a letter are lowercased Letters that follow a non-letter are upcased.

If keep_upper = true, already uppercase letters are not lowercased.

SEE : Char::is_letter for the definition of letter.

assert "jAVASCRIPT".capitalized == "Javascript"
assert "i am root".capitalized == "I Am Root"
assert "ab_c -ab0c ab\nc".capitalized == "Ab_C -Ab0C Ab\nC"
assert "preserve my ACRONYMS".capitalized(keep_upper=true) == "Preserve My ACRONYMS"

Property definitions

core $ Text :: capitalized
	# Returns a capitalized `self`
	#
	# Letters that follow a letter are lowercased
	# Letters that follow a non-letter are upcased.
	#
	# If `keep_upper = true`, already uppercase letters are not lowercased.
	#
	# SEE : `Char::is_letter` for the definition of letter.
	#
	# ~~~
	# assert "jAVASCRIPT".capitalized == "Javascript"
	# assert "i am root".capitalized == "I Am Root"
	# assert "ab_c -ab0c ab\nc".capitalized == "Ab_C -Ab0C Ab\nC"
	# assert "preserve my ACRONYMS".capitalized(keep_upper=true) == "Preserve My ACRONYMS"
	# ~~~
	fun capitalized(keep_upper: nullable Bool): SELFTYPE do
		if length == 0 then return self

		var buf = new Buffer.with_cap(length)
		buf.capitalize(keep_upper=keep_upper, src=self)
		return buf.to_s
	end
lib/core/text/abstract_text.nit:1376,2--1397,4

core $ Buffer :: capitalized
	redef fun capitalized(keep_upper) do
		if length == 0 then return self

		var buf = new Buffer.with_cap(byte_length)
		buf.capitalize(keep_upper=keep_upper, src=self)
		return buf
	end
lib/core/text/abstract_text.nit:1859,2--1865,4