Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1622

Add $cpLength and $cpSubstr expressions which work via code points

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4
    • Component/s: Linq
    • Labels:
      None
    • Sprint:
      C# Sprint 41

      Description

      Syntax

      {$substrBytes: <expression>}
      {$substrCP: <expression>}
      

      Examples

      Input

      {_id: 0, string: "ελληνικά"}
      

      Pipeline

      db.coll.aggregate([{
          $project: {
              byteSubstr: {$substrBytes: ["$string", 0, 4]},
              cpSubstr: {$substrCP: ["$string", 0, 4]}
          }
      }])
      

      Output

      {_id: 0, byteSubstr: "ελ", cpSubstr: "ελλη"}
      

      Additional Notes

      • Will not add any new query functionality to work with strings.
      • $substrBytes will error if it starts or ends in the middle of a code point.
      • $substrCP will error on any input that is detected to be invalid UTF-8.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rstam Robert Stam
              Reporter:
              rathi.gnanasekaran Rathi Gnanasekaran
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: