LibUv Networking (#65)
This commit is contained in:
parent
ec6629fbe9
commit
5e2be2d7b6
69 changed files with 5612 additions and 586 deletions
|
|
@ -175,13 +175,13 @@ namespace Server.Network
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
public bool IsSafeChar(int c) => c >= 0x20 && c < 0xFFFE;
|
||||
private static bool IsSafeChar(int c) => c >= 0x20 && c < 0xFFFE;
|
||||
|
||||
public string ReadUTF8StringSafe(int fixedLength)
|
||||
{
|
||||
string s;
|
||||
|
||||
if (m_Reader.TryReadTo(out ReadOnlySpan<byte> span, (byte)'\0', true))
|
||||
if (m_Reader.TryReadTo(out ReadOnlySpan<byte> span, (byte)'\0'))
|
||||
s = Utility.UTF8.GetString(span.Length > fixedLength ? span.Slice(0, fixedLength) : span);
|
||||
else
|
||||
{
|
||||
|
|
@ -203,7 +203,7 @@ namespace Server.Network
|
|||
{
|
||||
string s;
|
||||
|
||||
if (m_Reader.TryReadTo(out ReadOnlySpan<byte> span, (byte)'\0', true))
|
||||
if (m_Reader.TryReadTo(out ReadOnlySpan<byte> span, (byte)'\0'))
|
||||
s = Utility.UTF8.GetString(span);
|
||||
else
|
||||
{
|
||||
|
|
@ -222,7 +222,7 @@ namespace Server.Network
|
|||
|
||||
public string ReadUTF8String() =>
|
||||
Utility.UTF8.GetString(
|
||||
m_Reader.TryReadTo(out ReadOnlySpan<byte> span, (byte)'\0', true) ? span :
|
||||
m_Reader.TryReadTo(out ReadOnlySpan<byte> span, (byte)'\0') ? span :
|
||||
m_Reader.Sequence.Slice(m_Reader.Position, m_Reader.Remaining).ToArray()
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue