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

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

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4
    • Affects Version/s: None
    • Component/s: Linq
    • None

      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.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            rathi.gnanasekaran Rathi Gnanasekaran
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: