Skip to content

Commit ec5cc57

Browse files
committed
Add new convenience overload
1 parent acaebf9 commit ec5cc57

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

NStack/strings/ustring.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,27 @@ public static ustring Make (params char [] chars)
449449
return new ByteBufferUString (chars);
450450
}
451451

452+
/// <summary>
453+
/// Initializes a new instance of the <see cref="T:NStack.ustring"/> class from an array of Runes.
454+
/// </summary>
455+
/// <returns>The make.</returns>
456+
/// <param name="runes">Runes.</param>
457+
public static ustring Make (IList<Rune> runes)
458+
{
459+
if (runes == null)
460+
throw new ArgumentNullException (nameof (runes));
461+
int size = 0;
462+
foreach (var rune in runes) {
463+
size += Utf8.RuneLen (rune);
464+
}
465+
var encoded = new byte [size];
466+
int offset = 0;
467+
foreach (var rune in runes) {
468+
offset += Utf8.EncodeRune (rune, encoded, offset);
469+
}
470+
return Make (encoded);
471+
}
472+
452473
/// <summary>
453474
/// Initializes a new instance of the <see cref="T:NStack.ustring"/> class from a block of memory and a size.
454475
/// </summary>

0 commit comments

Comments
 (0)