Skip to content

Commit 41cddaa

Browse files
committed
0.9
1 parent 723809a commit 41cddaa

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

NStack/NStack.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PropertyGroup>
66
<TargetFramework>netstandard1.6</TargetFramework>
77
<PackageId>NStack.Core</PackageId>
8-
<PackageVersion>0.8</PackageVersion>
8+
<PackageVersion>0.9</PackageVersion>
99
<Authors>Miguel de Icaza</Authors>
1010
<PackageLicenseUrl>https://github.com/migueldeicaza/NStack/blob/master/LICENSE.md</PackageLicenseUrl>
1111
<Owners>Miguel de Icaza</Owners>
@@ -17,7 +17,11 @@
1717

1818
It starts with a new string type that is focused on Unicode code-points as opposed to the historical chars and UTF-16 encoding and introduces a utf8 string that supports slicing</Description>
1919
<ReleaseVersion>0.3</ReleaseVersion>
20-
<PackageReleaseNotes>* Renamed some methods to match the equivalent methods in Char.
20+
<PackageReleaseNotes>0.9:
21+
Added ustring.ColumnWidth to return number of columns that a ustring takes in a console.
22+
23+
0.8:
24+
* Renamed some methods to match the equivalent methods in Char.
2125
* Introduced Substring (int start)
2226
* Introduced difference between this [int start, int end] and this [int start, object end] the latter used to mean "until the end", replacing '0' as the previous value for "until the end".
2327
* Introduced new method in Rune to measure the width in columns for console applications.</PackageReleaseNotes>

NStack/strings/ustring.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,22 @@ public ustring Substring (int start)
997997
/// <value>The rune count.</value>
998998
public int RuneCount => Utf8.RuneCount (this);
999999

1000+
/// <summary>
1001+
/// Returns the number of columns used by the unicode string on console applications. This is done by calling the Rune.ColumnWidth on each rune.
1002+
/// </summary>
1003+
public int ConsoleWidth {
1004+
get {
1005+
int total = 0;
1006+
int blen = Length;
1007+
for (int i = 0; i < blen;) {
1008+
(var rune, var size) = Utf8.DecodeRune (this, i, i - blen);
1009+
i += size;
1010+
total += Rune.ColumnWidth (rune);
1011+
}
1012+
return total;
1013+
}
1014+
}
1015+
10001016
/// <summary>
10011017
/// Copies the specified number of bytes from the the underlying ustring representation to the target array at the specified offset.
10021018
/// </summary>

0 commit comments

Comments
 (0)