本文整理汇总了C#中Utf8String类的典型用法代码示例。如果您正苦于以下问题:C# Utf8String类的具体用法?C# Utf8String怎么用?C# Utf8String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utf8String类属于命名空间,在下文中一共展示了Utf8String类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TryParse
public static bool TryParse(Utf8String utf8Text, out uint value, out int bytesConsumed)
{
Precondition.Require(utf8Text.Length > 0);
value = 0;
bytesConsumed = 0;
for (int byteIndex = 0; byteIndex < utf8Text.Length; byteIndex++)
{
byte nextByte = (byte)utf8Text[byteIndex];
if (nextByte < '0' || nextByte > '9')
{
if (bytesConsumed == 0)
{
value = default(uint);
return false;
}
else
{
return true;
}
}
uint candidate = value * 10;
candidate += (uint)nextByte - '0';
if (candidate >= value)
{
value = candidate;
}
bytesConsumed++;
}
return true;
}
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:33,代码来源:InvariantParser_uint.cs
示例2: DecodeInPlace
public void DecodeInPlace()
{
var list = new List<byte>();
for (int value = 0; value < 256; value++) {
list.Add((byte)value);
}
var testBytes = list.ToArray();
for (int value = 0; value < 256; value++) {
var sourceBytes = testBytes.Slice(0, value + 1);
var buffer = new byte[Base64.ComputeEncodedLength(sourceBytes.Length)];
var bufferSlice = buffer.Slice();
Base64.Encode(sourceBytes, bufferSlice);
var encodedText = new Utf8String(bufferSlice).ToString();
var expectedText = Convert.ToBase64String(testBytes, 0, value + 1);
Assert.Equal(expectedText, encodedText);
var decodedByteCount = Base64.DecodeInPlace(bufferSlice);
Assert.Equal(sourceBytes.Length, decodedByteCount);
for (int i = 0; i < decodedByteCount; i++) {
Assert.Equal(sourceBytes[i], buffer[i]);
}
}
}
开发者ID:jkotas,项目名称:corefxlab,代码行数:27,代码来源:BasicUnitTests.cs
示例3: EndsWithUtf8String
public void EndsWithUtf8String(string s, string pattern)
{
Utf8String u8s = new Utf8String(s);
Utf8String u8pattern = new Utf8String(pattern);
Assert.Equal(s.EndsWith(pattern), u8s.EndsWith(u8pattern));
}
开发者ID:Applied-Duality,项目名称:corefxlab,代码行数:7,代码来源:RandomTests.cs
示例4: BasicEncodingDecoding
public void BasicEncodingDecoding()
{
var list = new List<byte>();
for(int value=0; value < 256; value++) {
list.Add((byte)value);
}
var testBytes = list.ToArray();
for (int value = 0; value < 256; value++) {
var sourceBytes = testBytes.Slice(0, value + 1);
var encodedBytes = new byte[Base64.ComputeEncodedLength(sourceBytes.Length)].Slice();
var encodedBytesCount = Base64.Encode(sourceBytes, encodedBytes);
Assert.Equal(encodedBytes.Length, encodedBytesCount);
var encodedText = new Utf8String(encodedBytes).ToString();
var expectedText = Convert.ToBase64String(testBytes, 0, value + 1);
Assert.Equal(expectedText, encodedText);
var decodedBytes = new byte[sourceBytes.Length];
var decodedByteCount = Base64.Decode(encodedBytes, decodedBytes.Slice());
Assert.Equal(sourceBytes.Length, decodedByteCount);
for (int i=0; i<decodedBytes.Length; i++) {
Assert.Equal(sourceBytes[i], decodedBytes[i]);
}
}
}
开发者ID:jkotas,项目名称:corefxlab,代码行数:28,代码来源:BasicUnitTests.cs
示例5: NonAllocatingRead
public void NonAllocatingRead()
{
var jsonText = new Utf8String("{\"First\":\"John\",\"Age\":25}");
JsonDynamicObject json = JsonDynamicObject.Parse(jsonText);
Assert.Equal(new Utf8String("John"), json.First());
Assert.Equal(25U, json.Age());
}
开发者ID:jkotas,项目名称:corefxlab,代码行数:8,代码来源:JsonDynamicObjectTests.cs
示例6: JsonReader
public JsonReader(Utf8String str)
{
_str = str;
_index = 0;
_insideObject = 0;
_insideArray = 0;
TokenType = 0;
}
开发者ID:khalidabuhakmeh,项目名称:corefxlab,代码行数:8,代码来源:JsonReader.cs
示例7: JsonReader
public JsonReader(string str)
{
_str = new Utf8String(str);
_index = 0;
_insideObject = 0;
_insideArray = 0;
TokenType = JsonTokenType.Start;
}
开发者ID:Anniepoh,项目名称:corefxlab,代码行数:8,代码来源:JsonReader.cs
示例8: Equals
public bool Equals(Utf8String other)
{
if (Length != other.Length) return false;
for(int i=0; i<Length; i++) {
if (_bytes[i] != other.Bytes[i]) return false;
}
return true;
}
开发者ID:GrimDerp,项目名称:corefxlab,代码行数:8,代码来源:HttpReader.cs
示例9: JsonReader
public JsonReader(string str)
{
_str = new Utf8String(str);
_index = 0;
_insideObject = 0;
_insideArray = 0;
TokenType = 0;
_length = _str.Length;
}
开发者ID:powercode,项目名称:corefxlab,代码行数:9,代码来源:JsonReader.cs
示例10: JsonReader
public JsonReader(string str)
{
_str = new Utf8String(str).Trim();
_index = 0;
_insideObject = 0;
_insideArray = 0;
TokenType = 0;
_jsonStartIsObject = (byte)_str[0] == '{';
}
开发者ID:TerabyteX,项目名称:corefxlab,代码行数:9,代码来源:JsonReader.cs
示例11: LengthPointerTest
public unsafe void LengthPointerTest()
{
byte[] utf8Bytes = Encoding.UTF8.GetBytes("1258");
fixed (byte* bytes = utf8Bytes)
{
var utf8String = new Utf8String(bytes, utf8Bytes.Length);
Assert.Equal(4, utf8Bytes.Length);
}
}
开发者ID:IDisposable,项目名称:corefxlab,代码行数:9,代码来源:BasicUnitTests.cs
示例12: Bug869DoesNotRepro
//[Fact(Skip = "issue #869")]
public void Bug869DoesNotRepro()
{
var bytes = new byte[] { 0xF0, 0xA4, 0xAD, 0xA2 };
var utf8String = new Utf8String(bytes);
var str = "
|
请发表评论