ucs-jcn-addendum.txt

text/plain

Filename: ucs-jcn-addendum.txt
Type: text/plain
Part: 0
Message: Re: badly calculated width of emoji in psql
diff --git a/src/common/wchar.c b/src/common/wchar.c
index 43f1078ae6..467cb8921a 100644
--- a/src/common/wchar.c
+++ b/src/common/wchar.c
@@ -623,12 +623,6 @@ mbbisearch(pg_wchar ucs, const struct mbinterval *table, int max)
  *		category code Mn or Me in the Unicode database) have a
  *		column width of 0.
  *
- *	  - Other format characters (general category code Cf in the Unicode
- *		database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
- *
- *	  - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
- *		have a column width of 0.
- *
  *	  - Spacing characters in the East Asian Wide (W) or East Asian
  *		FullWidth (F) category as defined in Unicode Technical
  *		Report #11 have a column width of 2.
@@ -659,13 +653,12 @@ ucs_wcwidth(pg_wchar ucs)
 				   sizeof(combining) / sizeof(struct mbinterval) - 1))
 		return 0;
 
-	/*
-	 * if we arrive here, ucs is not a combining or C0/C1 control character
-	 */
+	/* binary search in table of wide characters */
+	if (mbbisearch(ucs, east_asian_fw,
+				   sizeof(east_asian_fw) / sizeof(struct mbinterval) - 1))
+		return 2;
 
-	return 1 +
-		mbbisearch(ucs, east_asian_fw,
-				   sizeof(east_asian_fw) / sizeof(struct mbinterval) - 1);
+	return 1;
 }
 
 /*