Skip to content

Commit ac83bb1

Browse files
committed
Add ToASCIIdj
1 parent 2348319 commit ac83bb1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

srb.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ var (
1111
toLat = strings.NewReplacer("Е", "E", "Р", "R", "Т", "T", "З", "Z", "У", "U", "И", "I", "О", "O", "П", "P", "Ш", "Š", "Ђ", "Đ", "А", "A", "С", "S", "Д", "D", "Ф", "F", "Г", "G", "Х", "H", "Ј", "J", "К", "K", "Л", "L", "Ч", "Č", "Ћ", "Ć", "Ц", "C", "В", "V", "Б", "B", "Н", "N", "М", "M", "Ж", "Ž", "е", "e", "р", "r", "т", "t", "з", "z", "у", "u", "и", "i", "о", "o", "п", "p", "ш", "š", "ђ", "đ", "а", "a", "с", "s", "д", "d", "ф", "f", "г", "g", "х", "h", "ј", "j", "к", "k", "л", "l", "ч", "č", "ћ", "ć", "ц", "c", "в", "v", "б", "b", "н", "n", "м", "m", "ж", "ž", "Љ", "Lj", "Њ", "Nj", "Џ", "Dž", "љ", "lj", "њ", "nj", "џ", "dž")
1212
toCyr = strings.NewReplacer("Lj", "Љ", "LJ", "Љ", "Nj", "Њ", "NJ", "Њ", "Dž", "Џ", "DŽ", "Џ", "lj", "љ", "nj", "њ", "dž", "џ", "E", "Е", "R", "Р", "T", "Т", "Z", "З", "U", "У", "I", "И", "O", "О", "P", "П", "Š", "Ш", "Đ", "Ђ", "A", "А", "S", "С", "D", "Д", "F", "Ф", "G", "Г", "H", "Х", "J", "Ј", "K", "К", "L", "Л", "Č", "Ч", "Ć", "Ћ", "C", "Ц", "V", "В", "B", "Б", "N", "Н", "M", "М", "Ž", "Ж", "e", "е", "r", "р", "t", "т", "z", "з", "u", "у", "i", "и", "o", "о", "p", "п", "š", "ш", "đ", "ђ", "a", "а", "s", "с", "d", "д", "f", "ф", "g", "г", "h", "х", "j", "ј", "k", "к", "l", "л", "č", "ч", "ć", "ћ", "c", "ц", "v", "в", "b", "б", "n", "н", "m", "м", "ž", "ж", "x", "кс", "w", "в", "y", "и", "X", "КС", "W", "В", "Y", "И")
1313
fixDj = strings.NewReplacer("Dj", "Đ", "DJ", "Đ", "dj", "đ")
14-
toASCII = strings.NewReplacer("š", "s", "đ", "dj", "č", "c", "ć", "c", "ž", "z", "Š", "S", "Đ", "Dj", "Č", "C", "Ć", "C", "Ž", "Z")
14+
toASCIIdj = strings.NewReplacer("š", "s", "đ", "dj", "č", "c", "ć", "c", "ž", "z", "Š", "S", "Đ", "Dj", "Č", "C", "Ć", "C", "Ž", "Z")
15+
toASCII = strings.NewReplacer("š", "s", "đ", "d", "č", "c", "ć", "c", "ž", "z", "Š", "S", "Đ", "D", "Č", "C", "Ć", "C", "Ž", "Z")
1516
htmlRegex, _ = regexp.Compile("(^|>)([^<]*)(<|$)")
1617
months = []string{"januar", "februar", "mart", "april", "maj", "jun", "jul", "avgust", "septembar", "oktobar", "novembar", "decembar"}
1718
weekdays = []string{"nedelja", "ponedeljak", "utorak", "sreda", "četvrtak", "petak", "subota"}
@@ -32,14 +33,19 @@ func FixDj(s string) string {
3233
return fixDj.Replace(s)
3334
}
3435

35-
// ToASCII replaces šđć螊ĐČĆŽ with sdjcczSDJCCZ
36+
// ToASCII replaces šđć螊ĐČĆŽ with sdcczSDCCZ
3637
func ToASCII(s string) string {
3738
return toASCII.Replace(s)
3839
}
3940

41+
// ToASCIIdj replaces šđć螊ĐČĆŽ with sdjcczSDJCCZ
42+
func ToASCIIdj(s string) string {
43+
return toASCIIdj.Replace(s)
44+
}
45+
4046
// HasCyr returns true if string contains at least one cyrillic character
4147
func HasCyr(s string) bool {
42-
return (strings.IndexAny(s, cyr) != -1)
48+
return strings.ContainsAny(s, cyr)
4349
}
4450

4551
// HTMLToCyr converts string that contains HTML tags from latin to cyrillic, preserving HTML tags in latin

0 commit comments

Comments
 (0)