Skip to content

Commit 617cc58

Browse files
committed
Starting...
0 parents  commit 617cc58

File tree

11 files changed

+157
-0
lines changed

11 files changed

+157
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 SimdUnicode authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SimdUnicode
2+
3+
This is a fast C# library to process unicode strings.

info/ORGANIZATION.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
We follow the recommended file and directory layout from
2+
https://learn.microsoft.com/en-us/dotnet/core/tutorials/testing-with-cli

info/REFERENCES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://sharplab.io/

src/Ascii.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
namespace SimdUnicode {
4+
public static class Ascii {
5+
public static bool IsAscii(this char c) => c < 128;
6+
public static bool IsAscii(this string s) {
7+
foreach (var c in s) {
8+
if (!c.IsAscii()) return false;
9+
}
10+
return true;
11+
}
12+
public static bool IsAscii(this ReadOnlySpan<char> s) {
13+
foreach (var c in s) {
14+
if (!c.IsAscii()) return false;
15+
}
16+
return true;
17+
}
18+
public static bool IsAscii(this Span<char> s) {
19+
foreach (var c in s) {
20+
if (!c.IsAscii()) return false;
21+
}
22+
return true;
23+
}
24+
public static bool IsAscii(this ReadOnlyMemory<char> s) => IsAscii(s.Span);
25+
public static bool IsAscii(this Memory<char> s) => IsAscii(s.Span);
26+
}
27+
}

src/SimdUnicode.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<TargetFramework>net7.0</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
</Project>

src/UTF16.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
namespace SimdUnicode {
4+
public static class UTF16 {
5+
public static bool IsUTF16(this char c) => c < 128;
6+
public static bool IsUTF16(this string s) {
7+
foreach (var c in s) {
8+
if (!c.IsUTF16()) return false;
9+
}
10+
return true;
11+
}
12+
public static bool IsUTF16(this ReadOnlySpan<char> s) {
13+
foreach (var c in s) {
14+
if (!c.IsUTF16()) return false;
15+
}
16+
return true;
17+
}
18+
public static bool IsUTF16(this Span<char> s) {
19+
foreach (var c in s) {
20+
if (!c.IsUTF16()) return false;
21+
}
22+
return true;
23+
}
24+
public static bool IsUTF16(this ReadOnlyMemory<char> s) => IsUTF16(s.Span);
25+
public static bool IsUTF16(this Memory<char> s) => IsUTF16(s.Span);
26+
}
27+
}

src/UTF8.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
namespace SimdUnicode {
4+
public static class UTF8 {
5+
public static bool IsUTF8(this char c) => c < 128;
6+
public static bool IsUTF8(this string s) {
7+
foreach (var c in s) {
8+
if (!c.IsUTF8()) return false;
9+
}
10+
return true;
11+
}
12+
public static bool IsUTF8(this ReadOnlySpan<char> s) {
13+
foreach (var c in s) {
14+
if (!c.IsUTF8()) return false;
15+
}
16+
return true;
17+
}
18+
public static bool IsUTF8(this Span<char> s) {
19+
foreach (var c in s) {
20+
if (!c.IsUTF8()) return false;
21+
}
22+
return true;
23+
}
24+
public static bool IsUTF8(this ReadOnlyMemory<char> s) => IsUTF8(s.Span);
25+
public static bool IsUTF8(this Memory<char> s) => IsUTF8(s.Span);
26+
}
27+
}

test/AsciiTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace tests;
2+
3+
public class AsciiTest
4+
{
5+
[Fact]
6+
public void Test1()
7+
{
8+
9+
}
10+
}

test/Usings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global using Xunit;

0 commit comments

Comments
 (0)