本文整理汇总了C#中Utf8String.GetEnumerator方法的典型用法代码示例。如果您正苦于以下问题:C# Utf8String.GetEnumerator方法的具体用法?C# Utf8String.GetEnumerator怎么用?C# Utf8String.GetEnumerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utf8String
的用法示例。
在下文中一共展示了Utf8String.GetEnumerator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CodePointValidation
public void CodePointValidation(string s)
{
var utf8string = new Utf8String(Encoding.UTF8.GetBytes(s));
IEnumerator<UnicodeCodePoint> codePoints = utf8string.GetEnumerator();
for (int i = 0; i < s.Length; i++)
{
Assert.True(codePoints.MoveNext());
Assert.Equal((uint)s[i], (uint)codePoints.Current);
}
Assert.False(codePoints.MoveNext());
}
示例2: AsciiStringEnumerators
public void AsciiStringEnumerators(string s)
{
Utf8String u8s = new Utf8String(Encoding.UTF8.GetBytes(s));
Utf8String.Enumerator e = u8s.GetEnumerator();
Utf8String.CodePointEnumerator cpe = u8s.CodePoints.GetEnumerator();
Assert.Equal(s.Length, u8s.Length);
for (int i = 0; i < s.Length; i++)
{
Assert.True(e.MoveNext());
Assert.True(cpe.MoveNext());
Assert.Equal((byte)s[i], (byte)u8s[i]);
Assert.Equal(u8s[i], e.Current);
Assert.Equal((byte)s[i], (byte)(uint)cpe.Current);
}
}
示例3: EnsureCodeUnitsOfStringByEnumeratingBytes
public void EnsureCodeUnitsOfStringByEnumeratingBytes(byte[] expectedBytes, Utf8String utf8String)
{
Assert.Equal(expectedBytes.Length, utf8String.Length);
Utf8String.Enumerator e = utf8String.GetEnumerator();
int i = 0;
while (e.MoveNext())
{
Assert.True(i < expectedBytes.Length);
Assert.Equal(expectedBytes[i], (byte)e.Current);
i++;
}
Assert.Equal(expectedBytes.Length, i);
}