Skip to content

Commit

Permalink
use correct char
Browse files Browse the repository at this point in the history
  • Loading branch information
JalonSolov committed Nov 4, 2023
1 parent e381eba commit 32a8a97
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions vlib/encoding/utf8/utf8_util.v
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,15 @@ fn up_low(s string, upper_flag bool) string {
if ch_len == 1 {
if upper_flag == true {
unsafe {
// ASCII lowercase is 0x61 -> 0x7a. Subtract 0x20 to uppercase.
c := str_res[index]
str_res[index] = if c >= 0x61 && c <= 0x7a { c - 0x20 } else { c }
// Subtract 0x20 (ASCII space char) from ASCII lowercase to convert to uppercase.
c := u8(s[index])
str_res[index] = if c >= u8(0x61) && c <= u8(0x7a) { c - u8(0x20) } else { c }
}
} else {
unsafe {
// ASCII uppercase is 0x41 -> 0x5a. Add 0x20 to lowercase.
c := str_res[index]
str_res[index] = if c >= 0x41 && c <= 0x5a { c + 0x20 } else { c }
// Add (ASCII space char) to ASCII uppercase to convert to lowercase.
c := u8(s[index])
str_res[index] = if c >= u8(0x41) && c <= u8(0x5a) { c + u8(0x20) } else { c }
}
}
} else if ch_len > 1 && ch_len < 5 {
Expand Down

0 comments on commit 32a8a97

Please sign in to comment.