// Uplow.kt Copyright (c) Kari Laitinen // http://www.naturalprogramming.com // 2020-10-31 File created. /* Kotlin documentation says that bitwise and operator works only with types int and long. */ fun convert_string_uppercase( given_string : String ) : String { var modified_string = StringBuilder( given_string ) var character_index = 0 while ( character_index < given_string.length ) { if ( given_string[ character_index ] >= 'a' && given_string[ character_index ] <= 'z' ) { val character_as_integer : Int = given_string[ character_index ].toInt() and 0x000000DF modified_string[ character_index ] = character_as_integer.toChar() } character_index ++ } return modified_string.toString() } fun main() { val test_string = "Kotlin is named after an island near St. Petersburg." print( "\n Original string: " + test_string ) val uppercase_string = convert_string_uppercase( test_string ) print( "\n After conversion: " + uppercase_string ) print( "\n Better conversion: " + test_string.toUpperCase() + "\n\n" ) }