-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support case-insensitive lookups (fixes gh #232)
- Loading branch information
Showing
12 changed files
with
3,525 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/perl -w | ||
use strict; | ||
use warnings; | ||
|
||
# Input data: https://www.unicode.org/Public/UCD/latest/ucd/CaseFolding.txt | ||
|
||
my %map; | ||
|
||
while (<>) { | ||
chomp; | ||
next if /^(#|\s*$)/; | ||
my($char, $status, $fold, $comment) = split /\s*;\s*/; | ||
if ($status =~ /^[CS]$/) { | ||
$comment =~ s/^#\s*//; | ||
# print " case 0x$char: return 0x$fold; // [$status] $comment\n"; | ||
$map{hex($char)} = hex($fold); | ||
} | ||
} | ||
|
||
my @valid_code_points = (0..0xD7FF, 0xE000..0x10FFFF); | ||
|
||
sub cp_to_str { | ||
my $cp = shift; | ||
my $fmt = $cp < 0x10000 ? "\\u%04X" : "\\U%08X"; | ||
return sprintf $fmt, $cp; | ||
} | ||
|
||
while (@valid_code_points) { | ||
my @cps = splice @valid_code_points, 0, 256; | ||
my $orig; | ||
my $folded; | ||
for my $cp (@cps) { | ||
my $fold = $map{$cp} // $cp; | ||
$orig .= cp_to_str($cp); | ||
$folded .= cp_to_str($fold); | ||
} | ||
print " {u8\"$orig\"sv, u8\"$folded\"sv},\n" if $orig ne $folded; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* vim:set ts=2 sw=2 sts=2 et: */ | ||
/** | ||
* \author Marcus Holland-Moritz ([email protected]) | ||
* \copyright Copyright (c) Marcus Holland-Moritz | ||
* | ||
* This file is part of dwarfs. | ||
* | ||
* dwarfs is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* dwarfs is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <string_view> | ||
|
||
namespace dwarfs::internal { | ||
|
||
std::string utf8_case_fold(std::string_view in); | ||
std::string utf8_case_fold_unchecked(std::string_view in); | ||
|
||
} // namespace dwarfs::internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.