Skip to content

Commit

Permalink
Remove documentation about special case "Bulgaria"
Browse files Browse the repository at this point in the history
  • Loading branch information
petarov committed May 15, 2024
1 parent e325b13 commit d045ab3
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

# Go workspace file
go.work
.vscode

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ tr.Encode("Стара планина")
// Output: Stara planina
tr.Encode("Горна Оряховица")
// Output: Gorna Oryahovitsa
tr.Encode("БЪЛГАРИЯ")
// Output: BULGARIA
```

# References
Expand Down
7 changes: 0 additions & 7 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,4 @@
//
// tr.Encode("Горна Оряховица")
// // Output: Gorna Oryahovitsa
//
// There is an edge case where according to Bulgarian law the name "БЪЛГАРИЯ"
// is an exception to the transliteration rule and must have its "Ъ"
// transformed into a "U" instead of an "A". For example:
//
// tr.Encode("БЪЛГАРИЯ")
// // Output: BULGARIA
package translitbg
29 changes: 0 additions & 29 deletions translitbg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,6 @@ func isUpperBGChar(r rune) bool {
return (r >= 1040 && r <= 1071) || r == 1037
}

// tryDoBulgaria returns true for the case where input s is the text "България".
// In this case the "ъ" needs to be trasformed into an "u" as the law dictates
func tryDoBulgaria(input string) (bool, string) {
runes := []rune(input)
dest := make([]rune, 8)

for i, r := range runes {
if BULGARIA_CYR_LOW[i] == r {
dest[i] = BULGARIA_LAT_LOW[i]
} else if BULGARIA_CYR_UP[i] == r {
dest[i] = BULGARIA_LAT_UP[i]
} else {
return false, ""
}
}

return true, string(dest)
}

func New() *TranslitBG {
pattern := "^\\w+$"
regex, err := regexp.Compile(pattern)
Expand All @@ -62,16 +43,6 @@ func New() *TranslitBG {
// Encode transliterates Bulgarian string input to its latin equivalent.
// Non-cyrillic characters will be left as they are.
func (tr *TranslitBG) Encode(input string) (string, error) {
length := len(input)
if length == 0 {
return "", nil
} else if length == 16 {
ok, result := tryDoBulgaria(input)
if ok {
return result, nil
}
}

source := bytes.NewBufferString(input)
dest := bytes.NewBuffer(nil)
ch_1 := ""
Expand Down
4 changes: 0 additions & 4 deletions translitbg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ func TestEdgeCases(t *testing.T) {
input string
expected string
}{
{"България", "Bulgaria"},
{"българия", "bulgaria"},
{"БЪЛГАРИЯ", "BULGARIA"},
{"БъЛгАриЯ", "BuLgAriA"},
{"ЖЕЗЪЛ", "ZHEZAL"},
{"жЕЗЪЛ", "zhEZAL"},
{"жезъл", "zhezal"},
Expand Down

0 comments on commit d045ab3

Please sign in to comment.