diff --git a/core/stringutil/initials.go b/core/stringutil/initials.go index 84eb3cdf..ffcec458 100644 --- a/core/stringutil/initials.go +++ b/core/stringutil/initials.go @@ -23,11 +23,11 @@ func MakeInitials(firstname, lastname string) string { b := "" if len(firstname) > 0 { - a = firstname[:1] + a = string([]rune(firstname)[:1]) } if len(lastname) > 0 { - b = lastname[:1] + b = string([]rune(lastname)[:1]) } return strings.ToUpper(a + b) diff --git a/core/stringutil/initials_test.go b/core/stringutil/initials_test.go index 18b18aab..7c192a1c 100644 --- a/core/stringutil/initials_test.go +++ b/core/stringutil/initials_test.go @@ -13,11 +13,13 @@ package stringutil import "testing" +// go test github.com/documize/community/core/stringutil -run TestInitials func TestInitials(t *testing.T) { in(t, "Harvey", "Kandola", "HK") in(t, "Harvey", "", "H") in(t, "", "Kandola", "K") in(t, "", "", "") + in(t, "Иванов", "Иванов", "ИИ") } func in(t *testing.T, firstname, lastname, expecting string) {