You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NStack/NStack.csproj
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@
18
18
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>
19
19
<ReleaseVersion>0.3</ReleaseVersion>
20
20
<PackageReleaseNotes>0.12: Rebuilt
21
+
Rebuild with an older Roslyn, to prevent regressions on Xamarin.
Copy file name to clipboardExpand all lines: NStack/strings/ustring.cs
+58-9Lines changed: 58 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -481,6 +481,26 @@ public static ustring Make (IEnumerable<Rune> runes)
481
481
returnMake(runes.ToList());
482
482
}
483
483
484
+
/// Initializes a new instance of the <see cref="T:NStack.ustring"/> class from an array of uints, which contain CodePoints.
485
+
/// </summary>
486
+
/// <returns>The make.</returns>
487
+
/// <param name="runes">Runes.</param>
488
+
publicstaticustringMake(uint[]runes)
489
+
{
490
+
if(runes==null)
491
+
thrownewArgumentNullException(nameof(runes));
492
+
intsize=0;
493
+
foreach(varruneinrunes){
494
+
size+=Utf8.RuneLen(rune);
495
+
}
496
+
varencoded=newbyte[size];
497
+
intoffset=0;
498
+
foreach(varruneinrunes){
499
+
offset+=Utf8.EncodeRune(rune,encoded,offset);
500
+
}
501
+
returnMake(encoded);
502
+
}
503
+
484
504
/// <summary>
485
505
/// Initializes a new instance of the <see cref="T:NStack.ustring"/> class from a block of memory and a size.
486
506
/// </summary>
@@ -934,8 +954,8 @@ public static ustring Make (byte [] buffer, int start, int count)
934
954
/// <summary>
935
955
/// Returns a slice of the ustring delimited by the [start, last-element-of-the-string range. If the range is invalid, the return is the Empty string.
936
956
/// </summary>
937
-
/// <param name="start">Start index, this value is inclusive. If the value is negative, the value is added to the length, allowing this parameter to count to count from the end of the string.</param>
938
-
/// <param name="end">This value is expected to be null to indicate that it should be the last element of the string.</param>
957
+
/// <param name="start">Byte start index, this value is inclusive. If the value is negative, the value is added to the length, allowing this parameter to count to count from the end of the string.</param>
958
+
/// <param name="end">Byte end index. This value is expected to be null to indicate that it should be the last element of the string.</param>
939
959
/// <remarks>
940
960
/// <para>
941
961
/// This is a companion indexer to the indexer that takes two integers, it only exists
@@ -944,6 +964,9 @@ public static ustring Make (byte [] buffer, int start, int count)
944
964
///
945
965
/// Some examples given the string "1234567890":
946
966
/// </para>
967
+
/// <para>
968
+
/// The indexes are byte indexes, they are not rune indexes.
969
+
/// </para>
947
970
/// <para>The range [8, null] produces "90"</para>
948
971
/// <para>The range [-2, null] produces "90"</para>
949
972
/// <para>The range [8, 9] produces "9"</para>
@@ -983,19 +1006,26 @@ public static ustring Make (byte [] buffer, int start, int count)
983
1006
}
984
1007
985
1008
/// <summary>
986
-
/// Returns the substring starting at the given position.
1009
+
/// Returns the substring starting at the given position in bytes from the origin of the Utf8 string.
1010
+
/// Use RuneSubstring to extract substrings based on the rune index, rather than the byte index inside the
1011
+
/// Utf8 encoded string.
987
1012
/// </summary>
988
1013
/// <returns>The substring starting at the specified offset.</returns>
989
1014
/// <param name="start">Starting point, the value is .</param>
990
-
public ustring Substring (intstart)
1015
+
public ustring Substring (intbyteStart)
991
1016
{
992
1017
intlen=Length;
993
-
if(start<0)
994
-
start=0;
995
-
return GetRange (start,len);
1018
+
if(byteStart<0)
1019
+
byteStart=0;
1020
+
return GetRange (byteStart,len);
996
1021
}
997
1022
998
1023
1024
+
public ustring RuneSubstring (intruneStart)
1025
+
{
1026
+
thrownew NotImplementedException ();
1027
+
}
1028
+
999
1029
/// <summary>
1000
1030
/// Gets a value indicating whether this <see cref="T:NStack.ustring"/> is empty.
0 commit comments