diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-01-04 18:59:08 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-01-04 18:59:48 +0100 |
| commit | 4c81d51a304fea9d9e902ad8b5a28d1d3b9a9a03 (patch) | |
| tree | 27e6145f493f70071e334fa5ebed99eff5135838 /src/data | |
| parent | d4409baee1a510bf3361820cbdf4118ed09baffd (diff) | |
| download | chawan-4c81d51a304fea9d9e902ad8b5a28d1d3b9a9a03.tar.gz | |
Merge data/idna with types/url
No need to have a separate directory for just 3 functions.
Diffstat (limited to 'src/data')
| -rw-r--r-- | src/data/idna.nim | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/src/data/idna.nim b/src/data/idna.nim deleted file mode 100644 index e78bb7d8..00000000 --- a/src/data/idna.nim +++ /dev/null @@ -1,51 +0,0 @@ -import std/unicode - -import utils/map - -include res/map/idna_gen - -type - IDNATableStatus* = enum - IDNA_VALID, IDNA_IGNORED, IDNA_MAPPED, IDNA_DEVIATION, IDNA_DISALLOWED - -func getIdnaTableStatus*(r: Rune): IDNATableStatus = - let i = uint32(r) - if i <= high(uint16): - let u = uint16(i) - if u in IgnoredLow: - return IDNA_IGNORED - if u in DisallowedLow: - return IDNA_DISALLOWED - for item in Deviation: - if item[0] == u: - return IDNA_DEVIATION - if DisallowedRangesLow.isInRange(u): - return IDNA_DISALLOWED - if MappedMapLow.isInMap(u): - return IDNA_MAPPED - else: - if i in IgnoredHigh: - return IDNA_IGNORED - if i in DisallowedHigh: - return IDNA_DISALLOWED - if DisallowedRangesHigh.isInRange(i): - return IDNA_DISALLOWED - if MappedMapHigh.isInMap(uint32(i)): - return IDNA_MAPPED - return IDNA_VALID - -func getIdnaMapped*(r: Rune): string = - let i = uint32(r) - if i <= high(uint16): - let u = uint16(i) - let n = MappedMapLow.searchInMap(u) - if n != -1: - return $MappedMapLow[n].mapped - let n = MappedMapHigh.searchInMap(i) - return $MappedMapHigh[n].mapped - -func getDeviationMapped*(r: Rune): string = - for item in Deviation: - if item[0] == uint16(r): - return $item[1] - return "" |