[geary/mjog/735-unicode-avatar-initials: 1/2] Util.Avatar::extract_initials_from_name: Don't strip diacritics
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/735-unicode-avatar-initials: 1/2] Util.Avatar::extract_initials_from_name: Don't strip diacritics
- Date: Tue, 17 Mar 2020 11:47:47 +0000 (UTC)
commit cfa414f08c0d1bd0c1a0e9b3e8086aa8f0b408a5
Author: Michael Gratton <mike vee net>
Date: Tue Mar 17 22:43:50 2020 +1100
Util.Avatar::extract_initials_from_name: Don't strip diacritics
Normalise to composed forms rather than decomposed forms, which would
replace diacritics on characters with combining chars, making them
disappear from the generated initials.
Fixes #735
src/client/util/util-avatar.vala | 2 +-
test/client/util/util-avatar-test.vala | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/src/client/util/util-avatar.vala b/src/client/util/util-avatar.vala
index 01075160..7405a9e1 100644
--- a/src/client/util/util-avatar.vala
+++ b/src/client/util/util-avatar.vala
@@ -72,7 +72,7 @@ namespace Util.Avatar {
}
public string? extract_initials_from_name(string name) {
- string normalized = name.strip().up().normalize();
+ string normalized = name.strip().up().normalize(-1, DEFAULT_COMPOSE);
string? initials = null;
if (normalized != "") {
GLib.StringBuilder buf = new GLib.StringBuilder();
diff --git a/test/client/util/util-avatar-test.vala b/test/client/util/util-avatar-test.vala
index 6fe612c3..87f2e5b5 100644
--- a/test/client/util/util-avatar-test.vala
+++ b/test/client/util/util-avatar-test.vala
@@ -22,6 +22,8 @@ public class Util.Avatar.Test : TestCase {
assert_string("AB", extract_initials_from_name("aardvark !baardvark"));
assert_string("AC", extract_initials_from_name("aardvark baardvark !caardvark"));
+ assert_string("Ó", extract_initials_from_name("óvári"));
+
assert_true(extract_initials_from_name("") == null);
assert_true(extract_initials_from_name(" ") == null);
assert_true(extract_initials_from_name(" ") == null);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]