File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ public static int ColumnWidth (Rune rune)
9494 if ( irune >= 0x7f && irune <= 0xa0 )
9595 return 0 ;
9696 /* binary search in table of non-spacing characters */
97- if ( bisearch ( irune , combining , combining . GetLength ( 0 ) ) != 0 )
97+ if ( bisearch ( irune , combining , combining . GetLength ( 0 ) - 1 ) != 0 )
9898 return 0 ;
9999 /* if we arrive here, ucs is not a combining or C0/C1 control character */
100100 return 1 +
Original file line number Diff line number Diff line change @@ -272,6 +272,21 @@ public static bool Valid (ustring str)
272272 return InvalidIndex ( str ) == - 1 ;
273273 }
274274
275-
275+ /// <summary>
276+ /// Given one byte from a utf8 string, return the number of expected bytes that make up the sequence.
277+ /// </summary>
278+ /// <returns>The number of UTF8 bytes expected given the first prefix.</returns>
279+ /// <param name="firstByte">Is the first byte of a UTF8 sequence.</param>
280+ public static int ExpectedSizeFromFirstByte ( byte firstByte )
281+ {
282+ var x = first [ firstByte ] ;
283+
284+ // Invalid runes, just return 1 for byte, and let higher level pass to print
285+ if ( x == xx )
286+ return - 1 ;
287+ if ( x == a1 )
288+ return 1 ;
289+ return x & 0xf ;
290+ }
276291 }
277292}
You can’t perform that action at this time.
0 commit comments