|
|
|
@ -114,7 +114,7 @@ object StringUtils { |
|
|
|
|
|
|
|
|
|
@SuppressLint("DefaultLocale") |
|
|
|
|
fun toFirstCapital(str: String): String { |
|
|
|
|
return str.substring(0, 1).toUpperCase() + str.substring(1) |
|
|
|
|
return str.substring(0, 1).uppercase(Locale.getDefault()) + str.substring(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -123,7 +123,7 @@ object StringUtils { |
|
|
|
|
fun halfToFull(input: String): String { |
|
|
|
|
val c = input.toCharArray() |
|
|
|
|
for (i in c.indices) { |
|
|
|
|
if (c[i].toInt() == 32) |
|
|
|
|
if (c[i].code == 32) |
|
|
|
|
//半角空格 |
|
|
|
|
{ |
|
|
|
|
c[i] = 12288.toChar() |
|
|
|
@ -133,9 +133,9 @@ object StringUtils { |
|
|
|
|
//if (c[i] == 46) //半角点号,不转换 |
|
|
|
|
// continue; |
|
|
|
|
|
|
|
|
|
if (c[i].toInt() in 33..126) |
|
|
|
|
if (c[i].code in 33..126) |
|
|
|
|
//其他符号都转换为全角 |
|
|
|
|
c[i] = (c[i].toInt() + 65248).toChar() |
|
|
|
|
c[i] = (c[i].code + 65248).toChar() |
|
|
|
|
} |
|
|
|
|
return String(c) |
|
|
|
|
} |
|
|
|
@ -144,15 +144,15 @@ object StringUtils { |
|
|
|
|
fun fullToHalf(input: String): String { |
|
|
|
|
val c = input.toCharArray() |
|
|
|
|
for (i in c.indices) { |
|
|
|
|
if (c[i].toInt() == 12288) |
|
|
|
|
if (c[i].code == 12288) |
|
|
|
|
//全角空格 |
|
|
|
|
{ |
|
|
|
|
c[i] = 32.toChar() |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (c[i].toInt() in 65281..65374) |
|
|
|
|
c[i] = (c[i].toInt() - 65248).toChar() |
|
|
|
|
if (c[i].code in 65281..65374) |
|
|
|
|
c[i] = (c[i].code - 65248).toChar() |
|
|
|
|
} |
|
|
|
|
return String(c) |
|
|
|
|
} |
|
|
|
@ -255,10 +255,10 @@ object StringUtils { |
|
|
|
|
var start = 0 |
|
|
|
|
val len = s.length |
|
|
|
|
var end = len - 1 |
|
|
|
|
while (start < end && (s[start].toInt() <= 0x20 || s[start] == ' ')) { |
|
|
|
|
while (start < end && (s[start].code <= 0x20 || s[start] == ' ')) { |
|
|
|
|
++start |
|
|
|
|
} |
|
|
|
|
while (start < end && (s[end].toInt() <= 0x20 || s[end] == ' ')) { |
|
|
|
|
while (start < end && (s[end].code <= 0x20 || s[end] == ' ')) { |
|
|
|
|
--end |
|
|
|
|
} |
|
|
|
|
if (end < len) ++end |
|
|
|
|