-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathLetterVariations.ahk
74 lines (66 loc) · 2.25 KB
/
LetterVariations.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
; Title:
; Link: github.com/lintalist/lintalist/blob/master/include/LetterVariations.ahk
; Author: Lintalist
; Date:
; for: AHK_L
/*
; LintaList Include
; Purpose: Return RegEx string to allow search for letter variations
; 'e' will search for [eéèêěĕẽẻėëēęếềễểẹệæǣǽœᵫ]
; Version: 1.7
; Date: 20190130 - added ẹ
;
; Includes Diacritics and Ligatures (not all) - see link below
; https://en.wiktionary.org/wiki/Appendix:Variations_of_%22a%22 ... ; etc
; see also https://www.autohotkey.com/boards/viewtopic.php?p=47793#p47793 for OP
;
; For discussion and suggestions:
; https://github.com/lintalist/lintalist/issues/33
; (easy to expand to include braille or language specific variations or other glyphs
; and Unicode artefacts)
*/
LetterVariations(text,c=0) {
; text : input text
; c : case sensitive 0 no, 1 yes
static lower:="[abcdeghiklnopqrstuvwxyz]", upper:="[ABCDEGHIKLNOPQRSTUVWXYZ]", Array := { "a" : "áàâǎăãảạäåāąấầẫẩậắằẵẳặǻæᴁᴭǽǣᴂᵆ"
, "b" : "ȸ"
, "c" : "ćĉčċç"
, "d" : "ďđðȸdzDzdžDž"
, "e" : "éèêěĕẽẻėëēęếềễểẹệæǣǽœᵫẹ"
, "g" : "ğĝġģǵǧǥ₲"
, "h" : "ȟĥħḩḫẖḣḥḧƕⱨⱶ"
, "i" : "íìĭîǐïĩįīỉịĵfiij"
, "k" : "ķĸǩḱḲḵ₭"
, "l" : "ĺľļłŀflljLjLJ"
, "n" : "ñńņňɲŋƞǹȵɳṅṇṉṋ"
, "o" : "óòŏôốồỗổǒöőõøǿōỏơớờỡởợọộᴔœɶȢȣᴕ"
, "p" : "ƥṕṗ"
, "q" : "ʠɊɋ"
, "r" : "ŕřȑȓɼɽɾṙṛṝṟ"
, "s" : "şŝșṩṥṡṧšśṣ"
, "t" : "ƫțţʈŧťṫṭẗṯ"
, "u" : "úùŭûǔůüǘǜǚǖűũųūủưứừữửựụᵫ"
, "v" : "ṽṿ"
, "w" : "ẃẁŵẅ"
, "x" : "ẍẋᶍ"
, "y" : "ýỳŷÿỹỷỵ"
, "z" : "źžż" }
if (c = 0) or (c = false) or (c = "")
for k, v in Array
text:=RegExReplace(text,"im)" k,"[" k v "]")
if (c = 1) or (c = true) {
for k, v in Array {
if RegExMatch(text,lower) {
StringLower, k, k
StringLower, v, v
text:=RegExReplace(text,"m)" k,"[" k v "]")
}
if RegExMatch(text,upper) {
StringUpper, k, k
StringUpper, v, v
text:=RegExReplace(text,"m)" k,"[" k v "]")
}
}
}
Return text
}