komikku/app/src/main/java/exh/util/String.kt

13 lines
403 B
Kotlin
Raw Normal View History

2021-06-02 06:10:36 +02:00
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package exh.util
import java.util.Locale
fun String.capitalize(locale: Locale = Locale.getDefault()) =
replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }