Skip to content

Commit 2932d77

Browse files
CSHARP-3876: Builders<T>.Filter.Regex(s => s.Name, keyword) doesn't work. (#628)
CSHARP-3876: Builders<T>.Filter.Regex(s => s.Name, keyword) Doesn't Work.
1 parent 51b39ca commit 2932d77

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/MongoDB.Bson/IO/CStringUtf8Encoding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static int GetBytes(string value, byte[] bytes, int byteIndex, UTF8Encodi
5656
else
5757
{
5858
// let fallback encoding handle surrogate pairs
59-
var bytesWritten = fallbackEncoding.GetBytes(value, 0, value.Length, bytes, byteIndex);
59+
var bytesWritten = fallbackEncoding.GetBytes(value, 0, value.Length, bytes, initialByteIndex);
6060
if (Array.IndexOf<byte>(bytes, 0, initialByteIndex, bytesWritten) != -1)
6161
{
6262
throw new ArgumentException("A CString cannot contain null bytes.", "value");

tests/MongoDB.Bson.Tests/IO/CStringUtf8EncodingTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public void GetMaxByteCount_should_return_expected_result(
5353
[InlineData("\\uffff", 0, 3, new byte[] { 0xef, 0xbf, 0xbf })]
5454
[InlineData("\\uffff", 1, 3, new byte[] { 0xef, 0xbf, 0xbf })]
5555
[InlineData("\\ud800\\udc00", 0, 4, new byte[] { 0xf0, 0x90, 0x80, 0x80 })] // surrogate pair
56+
[InlineData("a😋😋a", 0, 10, new byte[] { 0x61, 0xf0, 0x9F, 0x98, 0x8B, 0xf0, 0x9F, 0x98, 0x8B, 0x61 })] // surrogate pair
5657
public void GetBytes_should_return_expected_result(
5758
string value,
5859
int byteIndex,

0 commit comments

Comments
 (0)