Open-source multiplayer game server compatible with the RuneScape client https://www.openrs2.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
openrs2/util/src/main/java/dev/openrs2/util/StringUtils.kt

20 lines
421 B

package dev.openrs2.util
import dev.openrs2.util.charset.Cp1252Charset
fun CharSequence.indefiniteArticle(): String {
require(isNotEmpty())
return when (first().toLowerCase()) {
'a', 'e', 'i', 'o', 'u' -> "an"
else -> "a"
}
}
fun CharSequence.krHashCode(): Int {
var hash = 0
for (c in this) {
hash = ((hash shl 5) - hash) + Cp1252Charset.encode(c)
}
return hash
}