| ... | ... | @@ -254,7 +254,7 @@ pub fn isLower(c: u8) bool { |
| 254 | 254 | return inTable(c, tIndex.Lower); |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | | /// Returns whether the character has some graphical representation and can be printed. |
| 257 | /// Returns whether the character is printable and has some graphical representation. |
| 258 | 258 | /// This also returns `true` for the space character. |
| 259 | 259 | /// This is the same as `!isControl(c)`. |
| 260 | 260 | pub fn isPrint(c: u8) bool { |
| ... | ... | @@ -286,7 +286,7 @@ pub fn isUpper(c: u8) bool { |
| 286 | 286 | return inTable(c, tIndex.Upper); |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | | /// Returns whether the character is a hexadecimal digit. This is case-insensitive. |
| 289 | /// Returns whether the character is a hexadecimal digit. Case-insensitive. |
| 290 | 290 | pub fn isHex(c: u8) bool { |
| 291 | 291 | return inTable(c, tIndex.Hex); |
| 292 | 292 | } |
| ... | ... | @@ -296,7 +296,7 @@ pub fn isASCII(c: u8) bool { |
| 296 | 296 | return c < 128; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | | /// Uppercases the character and returns it as-is if it's already uppercased or not a letter. |
| 299 | /// Uppercases the character and returns it as-is if already uppercase or not a letter. |
| 300 | 300 | pub fn toUpper(c: u8) u8 { |
| 301 | 301 | if (isLower(c)) { |
| 302 | 302 | return c & 0b11011111; |
| ... | ... | @@ -305,7 +305,7 @@ pub fn toUpper(c: u8) u8 { |
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | | /// Lowercases the character and returns it as-is if it's already lowercased or not a letter. |
| 308 | /// Lowercases the character and returns it as-is if already lowercase or not a letter. |
| 309 | 309 | pub fn toLower(c: u8) u8 { |
| 310 | 310 | if (isUpper(c)) { |
| 311 | 311 | return c | 0b00100000; |
| ... | ... | @@ -314,7 +314,7 @@ pub fn toLower(c: u8) u8 { |
| 314 | 314 | } |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | | test "ascii character classes" { |
| 317 | test "ASCII character classes" { |
| 318 | 318 | const testing = std.testing; |
| 319 | 319 | |
| 320 | 320 | try testing.expect(!isControl('a')); |
| ... | ... | @@ -440,7 +440,7 @@ pub fn startsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool { |
| 440 | 440 | return if (needle.len > haystack.len) false else eqlIgnoreCase(haystack[0..needle.len], needle); |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | | test "ascii.startsWithIgnoreCase" { |
| 443 | test "startsWithIgnoreCase" { |
| 444 | 444 | try std.testing.expect(startsWithIgnoreCase("boB", "Bo")); |
| 445 | 445 | try std.testing.expect(!startsWithIgnoreCase("Needle in hAyStAcK", "haystack")); |
| 446 | 446 | } |
| ... | ... | @@ -449,7 +449,7 @@ pub fn endsWithIgnoreCase(haystack: []const u8, needle: []const u8) bool { |
| 449 | 449 | return if (needle.len > haystack.len) false else eqlIgnoreCase(haystack[haystack.len - needle.len ..], needle); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | | test "ascii.endsWithIgnoreCase" { |
| 452 | test "endsWithIgnoreCase" { |
| 453 | 453 | try std.testing.expect(endsWithIgnoreCase("Needle in HaYsTaCk", "haystack")); |
| 454 | 454 | try std.testing.expect(!endsWithIgnoreCase("BoB", "Bo")); |
| 455 | 455 | } |