Capitalize/decapitalize only ASCII characters across project

Use {de,}capitalizeAsciiOnly and to{Lower,Upper}CaseAsciiOnly where
possible, and stdlib's functions with Locale.US everywhere else.

Otherwise, if the default system locale is Turkish, the capital latin
letter "I" is transformed in toLowerCase to "ı" (see
66bc142f92/libraries/stdlib/jvm/test/text/StringJVMTest.kt (L119)),
which for example breaks the codegen for `intArrayOf` in
KT-25400/KT-43405.

Similarly, lower case latin letter "i" is transformed to "İ".

 #KT-13631 Fixed
 #KT-25400 Fixed
 #KT-43405 Fixed
This commit is contained in:
Alexander Udalov
2020-11-17 20:26:19 +01:00
parent 5d4b0b19d4
commit 77a9d14f93
53 changed files with 173 additions and 121 deletions

View File

@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.konan.target
import java.util.*
/**
* Name of a preset used in the 'kotlin-multiplatform' Gradle plugin to represent this target.
*/
@@ -19,5 +21,5 @@ val KonanTarget.presetName: String
private fun evaluatePresetName(targetName: String): String {
val nameParts = targetName.split('_').mapNotNull { it.takeIf(String::isNotEmpty) }
return nameParts.asSequence().drop(1).joinToString("", nameParts.firstOrNull().orEmpty(), transform = String::capitalize)
return nameParts.asSequence().drop(1).joinToString("", nameParts.firstOrNull().orEmpty()) { it.capitalize(Locale.US) }
}